What you do is this:
- spend btc with a transaction and get it included in the chain.
- start mining blocks starting from before your transaction in secret
- include a trnasaction to a different address in the secret chain
- broadcast the secret chain once it's longer than the "official" one
- since your chain is longer, your chain is now the official one. All the transactions in the other chain are now discarded
The Bitcoin blockchain constantly "forks" for the latest 1-2 blocks. If you sell your car for BTC and hand over the car the moment you see the latest block contains the transaction where the BTC enters your wallet, you may see 1h later that the longest chain does NOT contain your transaction, and in fact your transaction is now invalid, because the buyer wallet has sent all the money somewhere else.
Here an attacker controlling 51% of mining power decides to not play by the rules; we are considering what that means for everybody else. For Bitcoin it means they can block transactions forever, and they can double-spend.
Obviously if the attacker plays by the rules there is no attack.