When you swap on a DEX, your transaction usually goes into the public mempool first — basically a waiting room where everyone (including bots) can see what you’re about to do.
MEV bots live in that waiting room. They watch for juicy trades, then jump ahead of you (front-run), buy before you and sell it immediately after you (sandwich attack) to profit off it.