In the event of a 51% attack, nodes with a majority of the network [[Hashpower]] have to collude to effectively split the blockchain, creating a competing blockchain. A [[Practical Byzantine Fault Tolerance|Byzantine fault-tolerant]] or [[Anti-fragility|anti-fragile]] system should rebound from such an attack because they are computationally unsustainable in practice. How do blockchain implementations specifically solve this?
Nodes are allowed to validate blocks largely because of the work performed (or money at stake) in [[mining]] and [[staking]] ecosystems. Nodes attacking the Bitcoin network, for example, could perform an enormous amount of work (i.e., [[Proof of Work]]) only to have all of their blocks invalidated (effectively wasting terahashes of [[Hashpower|hashpower]]). Similarly, validator nodes locking up funds on a [[Proof of Stake]] blockchain stand to lose far more economic value than could be gained from an attack.
Critically, the longest chain wins on the basis of consensus; network nodes must agree the chain is correct and that it includes only valid blocks. Still, it is possible for a chain to split during an attack (or even if two blocks are mined nearly simultaneously). Remember, though, the majority of nodes in the system must _finally_ confirm one block _or_ the other on the basis of time order, and then add the new block to the confirmed chain, resulting in a longest chain.
Theoretically, a few blocks could be mined before malicious behavior is detected, and once realized, the majority of nodes could jump back to the correct chain, invalidating the bad blocks. However, this has not happened to any notable [[Proof of Work]] blockchains yet, which is why the current implementations are considered _probabilistic_ solutions to the [[Byzantine Generals Problem]]. Maintaining a global state without defection from network participants, a blockchain has demonstrated the property of [[immutability]].