Order books need market makers quoting both sides continuously, which is operationally heavy on-chain. Automated market makers replaced the book with a pool and a formula: anyone can trade against the pool, and the price is a function of its balances.
The constant product
The classic AMM invariant, introduced by Uniswap, is disarmingly small:
x * y = k
x reserve of token A
y reserve of token B
k constant preserved by every trade
price of A = y / xBuying token A removes some x from the pool, so y must rise to keep k constant: the price moves against you as your trade grows. That curvature is slippage, and it is the mechanism, not a bug.
Liquidity providers
Pools are funded by liquidity providers who earn trading fees but accept impermanent loss: when prices diverge, the pool rebalances against them, and holding the assets outright would sometimes have paid more.