What happens in the bitcoin network when two miners solve a block at the same time?
The one with the longest chain wins.
All transactions on the stale/orphaned block will go back to the mempool.
What is a stale block? / How do stale blocks occur?
It is when 2 miners mine a block at the exact same time thou only one can be appended to the blockchain and the other becomes stale.
After network consensus has been reached, the one with the shortest chain will become stale. All transactions within the stale block will head back to the mempool.
It is important to wait for more than one block to be confirmed to ensure that your block is used and not dropped from the blockchain.
Yes, the recommended time frame is 6 confirmations to ensure that the block is appended to the blockchain and has not become stale.