Each block commits to the previous block in the block header by including the previous block's hash. A block's hash is defined as the output of hashing the block header, and for a block to be valid, this hash must fulfill the current difficulty requirement. While blocks can have more than one child block, the Bitcoin network finally agrees on just one best chain. In the best chain there is only one block at each height, so while blocks can have multiple child blocks, only one of them will be relevant in the longterm.
Therefore normally previous hash of B is correct, but previous hash of A should be changed to the hash of B.
Firstly, changing even a single bit in the block header will cause the hash of the block header to come out differently (see e.g. Mastering Bitcoin (Ch8, section "Mining the Block")). It's astronomically unlikely that the new hash also fulfills the difficulty statement. Therefore, the modified block header would no longer represent a valid block.
Secondly, given that A and B were drawing on the same set of unconfirmed transactions when they were found, it's extremely likely that the transactions included in the blocks for confirmation have some overlap. However, each transaction can only be included in one block, because each transaction output can only be spent once, and therefore the inputs of a transaction that was already confirmed are no longer available in a later block. It follows that A would likely include invalid transactions if it were following B.
So, once both A and B were found, and both have each independently committed to block L as their predecessor as well as including some of the same transactions, the blocks A and B are competing to be part of the best chain and exclusive to each other.