For more technical details:
The thing to understand is that 'bitcoins' actually exist as 'unspent transaction ouputs' (UTXO)s. Here is some info comparing the UTXO model, to the 'accounts model'.
In your first example, Bob would create a transaction that 'consumes' some UTXOs in his wallet that sum to a total ≥5 BTC, and send it to Alice. If the total was more than exactly 5, then Bob's transaction would include a change address that pays the extra back to himself. Bob creates and broadcasts this transaction.
Now, assuming he had exactly 10 BTC in his wallet (and ignoring tx fees), in order for Bob to send Uncle Tom 5 BTC immediately, he will need to make a transaction that includes the change UTXO created in the transaction sent to Alice. He does this, and broadcasts it to the network.
Both of these transactions can be mined in the same block, or they can be mined in separate blocks, but the important thing is: Alice's transaction must come first, since it creates a UTXO that is spent in Uncle Tom's transaction. Even within a block, the order of transactions matters in this way. First Alice's, then Uncle Tom's. The other way around would create an invalid block that the network would reject.
In the second example, Bob would sum up all the UTXOs in his wallet, and create a 10 BTC transaction to send to Alice, but he would also use the same UTXOs to create a transaction to send to Uncle Tom.
Lets say that Bob strategically broadcast these two transactions to the network, so that about half the network heard about Alice's transaction first, and the other half heard about Uncle Tom's transaction first.
In this case, only one transaction will eventually be 'confirmed' by being included in a block, because all of Bob's UTXOs can only be consumed once! A second attempt would be rejected by the network as invalid. So whichever transaction is included in a block first will be the winner, though you may want to wait a few confirmations to be completely sure. Any nodes that heard about the other transaction first will simply discard it once they hear about the winning transaction being included in a block.