Digital money with no central bank faces an obvious attack: grab the ledger and edit it -- erase your payment, inflate your balance. Blockchains defeat this not with guards but with math, and the trick is easier to see one block at a time. Transactions get grouped into blocks, and each block gets a fingerprint: a hash, the output of a math formula that turns the block's contents into a fixed code. Change even a single character inside the block, and the formula produces a completely different fingerprint -- the change is instantly visible.
The chain part is what makes this unbreakable. Every new block does not just carry its own hash; it embeds the previous block's hash inside itself. The blocks are linked like a line of sealed envelopes, each one holding a copy of the seal on the envelope before it. That means the current block's fingerprint actually certifies the entire history behind it.
Now run the hacker's play: go back and alter one old transaction. The edited block's hash changes -- fingerprint broken. But the next block still contains the old hash, so the link no longer matches, and the break cascades: every block after the tampered one now carries a mismatched seal. The entire chain from that point forward is visibly broken, the whole network sees it at once, and the fraud is rejected. To get away with it, the attacker would have to redo the seals of every following block faster than the rest of the world keeps adding new ones -- which is why the ledger's history is called immutable.
Notice what this achieves without a central bank: no administrator has to catch the fraud, because the math does the alarming. The security is not "nobody can touch the file" -- the file can be touched; it is that any touch announces itself and propagates a visible crack down the chain. Trust moves from a gatekeeper to arithmetic.
So the answer to "how does a blockchain stop hackers?" is a chain of fingerprints: blocks of transactions, hashes as seals, each block certifying the one before. Editing history does not delete the evidence -- it manufactures proof of the attempt, signed across every block that comes after.