The phrase "longest chain" is an oversimplification that is often used to explain bitcoin to newbies, but it just leads to the exact misunderstanding that you seem to be having now.
Bitcoin doesn't literally go with the "longest chain" or the "greatest blockheight". It goes with the highest proof-of-work. Bitcoin will happily accept a shorter chain with a lower blockheight in place of the current chain if that lower blockheight chain had a different difficulty adjustment and therefore those (fewer) blocks were solved at a high enough difficulty.
Actually the term Longest Chain is Accurate , the reason being is this,
The Clients will not compare Chain Difficulty until the Block #s are the same #,
Meaning if your Fake chain is on Block 5000 and it has a higher difficulty and the True Chain is on Block 5001 with a lower difficulty , until your fake chain hits block 5001,
my Client will not compare Blockchains, so yours can not take over.
Plus what I am saying is not Theory , but what happened with the Miners did decide to rewrite some of the Chain in March 2013.
The 0.7 chain quickly caught up to being only 10 blocks behind, then 8 blocks, and at 06:19 both chains converged to the same length at block 225454, leading to nearly all remaining miners abandoning the other.
https://bitcoinmagazine.com/articles/bitcoin-network-shaken-by-blockchain-fork-1363144448Article did state that the Miners that overwrote the blockchain controlled 70% of the HashRate.
FYI:
On a side node since the Chinese Mining Pools have shown over 70% hashrate in the past year,
it basically means they could easily rewrite the last ~10 hours or so of BTC Transactions whenever they feel like it.
BTC the Chinese Controlled Digital Currency.
LOL,
BTC= BETTER THANK CHINA