How a transaction is permanently accepted by the blockchain?
If the chain of the miner B grows faster than the chain of the miner A, then the transaction A will never be accepted (like it never happened).


The transaction A is still unconfirmed in the mempool for any nodes following the best chain building on miner B's block. Any subsequent block is free to include it. The best chain has only one block at each height. Any competing blocks that don't end being part of the best chain are irrelevant for the network's state. So, if the block mined by miner A ends up being in the best chain, transaction A gets confirmed in A's block. If the block mined by miner B ends up being in the best chain, transaction A is free to get mined in the subsequent blocks following the block mined by B.

Confirmation of transaction is always probabilistic. Theoretically, an arbitrary long part of the chaintip could be reorganized to a better chain. It's just increasingly unlikely the longer the tip is. Many users consider transactions with six confirmations to be reliably confirmed. For smaller amounts, they may even trust fewer confirmations, larger amounts may cause the recipient to wait longer.