I've heard the term "orphaned blocks" being tossed around here and on Reddit. Can someone please explain what orphaned blocks are and what happens to them?
An orphaned block refers to a block that was originally accepted by the network (a part of the network, anyway) as a valid block with a valid hash and valid transactions.
Due to the physical constraints of computers and the internet, a block that is solved by a miner and contributed to the network is not instantly propagated to the rest of the network. At minimum, it could take several seconds for data to transfer around the world. Due to this potential time lag, two miners may effectively simultaneously solve the same block. There will be nodes geographically closer to miner A than miner B, and vice versa, so the network will be temporarily split into two very similar but different chains, as the nodes broadcast to one another what they believe to be the most recently mined block.
Eventually, one of the two chains will demonstrably have a greater proof-of-work than the other, and the nodes on the other chain will update/reorganize their blockchain records/database accordingly and begin to only accept transactions on the chain with the greater proof-of-work.
Orphaned blocks are the legitimate blocks from the chain that lost out to the chain with a greater proof-of-work.
If a transaction was reflected on the 'B' chain, in an orphaned block, but not the 'A' chain, then once the network subsequently is fully on the 'A' chain, that transaction from the B chain will revert to being unspent (or will have been subsequently mined on the 'A' chain). Spent outputs do not get lost on a 'B' chain, since the history of any 'B' chain spends is effectively erased once the network accepts the 'A' chain.
(Note, I used 'A' and 'B' for example purposes only, with 'A' as the chain that ends up being the "true" chain, as demonstrated by its greater proof-of-work.)