Why it happens
On an order book, a large market order eats through several price levels. On a DEX, your trade itself moves the pool's price, and other trades may land before yours. Either way you can receive less than the quoted amount.
Slippage tolerance
Wallets and DEXs let you set a maximum acceptable slippage, often 0.5% to 1%. If the price moves more, the trade fails instead of filling badly. Setting it too high invites sandwich bots that profit by trading around your order.