how does bitcoin know which one is utxo? Let's say John gave 5 BTC to me. So, John took his unspent outputs and put it into inputs to create a transaction.  Let's say John already had a transaction which was holding exactly that amount of BTC.
Now, How can John not spend 5 BTC anymore ?  The output John used to give me 5BTC is still on Blockchain. So, does node go to that output transaction and mark it as spent ? how does it mark it as spent?
To answer the title, utxos are entirely consumed and refered in transactions inputs.

Now, How can John not spend 5 BTC anymore ?

As long as the transaction spending it is in the most PoW block chain, no.

The output John used to give me 5BTC is still on Blockchain. So, does node go to that output transaction and mark it as spent ?

If a valid transaction consumes it in a next block, it is marked as spent and not available anymore.

how does it mark it as spent?

By updating a database commonly refered to as &quot;the utxo set&quot; in which are recorded not-yet-spent UTXOs. See How is a Transaction Output Marked as Spent? .
You likely want to give a look to questions regarding coin referencing and consumption by transactions, for example:

How is the UTXOs of each partially-spent TxIn determined?
Why is there &quot;Change&quot; in Bitcoins?