What if the node processing this new invalid transaction had not yet received the last update? In other words, what if it had not yet seen that C transferred 50 coins to B already?
It would not be able to say the transaction was invalid and so it would accept it. This is a fork. The system processing the invalid transaction now has a different ledger from the rest of the world: Because the time it takes for a transaction to propagate to all the nodes in the network will differ for each node, everyone will have a slightly different view of the order that those transactions happened in.
But that order can be critically important, as we saw above. So who is right and how to get everyone to agree on that? Consensus through Proof of Work First the question of who is right. Is there even an objective order of transactions? General Relativity suggests that actually, there is not. So which order of transactions we accept is actually not that important, as long as all nodes agree on it.
So how to get them to agree? This is where consensus through Proof of Work comes into play. Each node processing transactions encodes it’s view of reality the order of transactions it thinks is correct into a block and then solves a cryptographic puzzle, attaching the answer to the block. The role of this Proof of Work is that it acts as a collateral; the processing node had to do work, which means spend real-world money, to create that block.
This means it has a stake in that block being accepted. A better way to describe a wallet is something that “stores the digital credentials for your bitcoin holdings”  and allows one to access and spend them.
Bitcoin uses public-key cryptographyin which two cryptographic keys, one public and one private, are generated. There are three modes which wallets can operate in. They have an inverse relationship with regards to trustlessness and computational requirements.