Centralised exchanges, both in traditional markets and in crypto, operate by means of the order book model. This means that a buyer or seller posts an order, and then this order is executed when someone else fills it with a corresponding and opposite buy/sell order. This works well only because centralised exchanges use market makers, i.e. entities that agree to always buy or sell at a certain price (and they make money due to the difference between the buy and sell price). Without market makers, an exchange wouldn’t be liquid enough, because it would take a very long time for an order to be filled.
Decentralised exchanges (DEXs), on the other hand, need to work differently. Implementing an order book model on the blockchain (e.g. with Ethereum in its current state) would be impractical, as every transaction costs a gas fee, and an order book exchange relies on the ability to place a large number of orders (many of which don’t end up being filled).