If two miners pick up exactly the same transaction for mining, how do we ensure that the transaction is not included in the two different blocks created by each of the two miners.
In each blockchain branch there can only be one block at every height as every block references their ancestor.
If a block includes a transaction that was already confirmed by one of their ancestors, the block is invalid. Invalid blocks are rejected by the nodes in the network. Therefore, one chain branch can never confirm the same transaction more than once.
If there are two blocks at the same height in the blockchain confirming the same transaction, that's fine. They are already competing as only one of them can be part of the longest chain anyway. The other will become stale as the majority chain moves forward.
It will be included in two (or more) different blocks. But only one of those blocks will propagated to the network and get picked up by other miners, become part of the "longest chain" and subsequently be extended.
So it doesn't matter if at any one time there are forks at the end of the "blockchain", it matters only that one representation is persistent.