For example, from what I understand,
If Alice and Bob share an Bitcoin Account that holds 500 Bitcoin.
This statement is the root of your confusion.
Bitcoin does not have an account model -- like a bank -- but a UTXO model (like cash)
Think of every bitcoin payment (output) a wallet receives as a distinct cash bill.
So a wallet is a collection of "bills" (i.e output), so there's no way that Alice and Bob can share a wallet securely, but assuming for the sake of discussion that they have the same wallet.dat file or mnemonic seed phrase corresponding to the ownership of certain UTXOs worth 500
BTCWhatever happens depends on if the 500
BTC is in 1 UTXO or split in many UTXOs , and the amount being spent.
(continuing the analogy, it depends if the 500
BTC is in one 500 currency note or split in many eg $50 bills.)
Alice could spend all 500 bitcoins on a car in North America when Bob spends it on a different car
in Asia.
Since Alice spends ALL the UTXOs, Bob CANNOT spend the same UTXOs again, as other nodes in the network will reject it as they already have a conflicting transaction in their mempool.
Both transactions would go to "pool" to be processed.
Note that there is no global pool, but each node has its own mempool, so it's possible that both conflicting transactions spending the same UTXO get propagated.
Boh of them will be processed in the next block.
Only ONE of them CAN be added to a block.
Even though Alice's transaction went to miner A and he added it to his candidate block and is trying to find the target, while Bob's transaction went to miner B who also adds it to his candidate block, eventually one of them will find a valid block and whichever transaction is included in the block is the valid one, and the other transaction is rendered invalid and CANNOT be added to the blockchain again.
So if it was Alice's transaction that was mined, Bob's transaction is no longer valid and can't be mined; if it was Bob's transaction that was mined, Alice's transaction is invalid and can no longer be mined.
The blockchain is the arbiter and its decision is final.
What I don't understand is, 1) Would the transaction be visible on explorer site ? Both of them ?
Block explorers get their information from full nodes.
If , for example, Blockchain.info's node(s) first saw Alice's transaction when she broadcast it, it will display the transaction as unconfirmed, and it WILL NOT accept Bob's transaction since Alice's transaction spends the same UTXO, and so it will only show Alice's.
If Blockchair saw Bob's transaction first, it will not accept Alice's transaction, and will show Bob's transaction as unconfirmed.
When one transaction is finally included in a block, whichever node contained the invalid transaction will discard it in favour of the mined one.
2) I get that maybe a few blocks later, the longest chain would be taken and one of the transactions
would be revoked.
Imagine a rare case where miner A above mined Alice's transaction, while miner B simultaneously mined Bob's transaction.
Both blocks are valid, and there are 2 competing blocks..whichever block is mined on becomes the Prefered block because it has the most proof of work.
If the block containing Bob's transaction is mined on by other miners then the block containing Alice's transaction will eventually be orphaned by other nodes and Bob's transaction is the valid one.
But how is this reliable at all? The two cars are probably in possession of Alice and Bob already.
The seller needs to wait at least 4 blocks after the transaction is complete?
You answered your question yourself.
For merchants selling expensive goods, they have to wait for a certain number of blocks to be sure that the transaction that pays them won't be overwritten by a longer block with more proof for work.
6 confirmations is commonly but more expensive items can call for more confirmations eg 144 blocks (1 day)
Also, regarding the 1st question, what happens on the explorer when the longest chain is taken ??
The other one is dropped.