Double spending means using the same money twice. With cash, it is physically impossible: once you hand over a banknote, you no longer have it. Digital data can be copied endlessly, so for digital money this was the central unsolved problem.
The old solution: a middleman
Banks and payment companies solve it by keeping a central ledger. When you pay, they subtract the amount from your balance. If you try again, they refuse. This works, but everyone has to trust the middleman, and the middleman can block, reverse or censor payments.
Bitcoin's solution
Bitcoin replaces the middleman with a public ledger that everyone can check:
1. Coins are outputs. Every bitcoin amount is a UTXO. Spending one marks it as used, and every node keeps track of which outputs are still unspent.
2. Conflicts are rejected. If two transactions try to spend the same output, nodes accept only one. A block containing both is invalid.
3. Order is settled by work. Which transaction came first is decided by which one ends up in the chain with the most proof of work. Once it is buried under several blocks, reversing it would require redoing all that work.
Can it still happen?
An unconfirmed transaction in the mempool can still be replaced. That is why merchants wait for a confirmation for larger payments. Six confirmations, about an hour, is a common rule of thumb for high-value transfers. The real threat is a "51% attack", where someone controls most of the hash power and rewrites recent blocks. On Bitcoin this would be extraordinarily expensive and has never happened.
Solving double spending without a trusted party is the breakthrough that made Bitcoin possible.