What Is a DEX (Decentralized Exchange)?

Peer-to-peer cryptocurrency trading becomes reality through decentralized exchanges, but how do they actually keep your assets secure?