I know some altcoins have features that allow senders to attach messages to transactions and using those features, exchange services distinguish the sender. However, I don't know if there's such a function in Bitcoin. How can exchanges tell who paid them without such a feature?
Exchanges generate a new address for each user when a user wants to deposit, so when they receive a deposit to a specific address, they know who to credit the deposit to.
Since Bitcoin does not use accounts, there is no need for the exchange to consolidate their received Bitcoin. They can simply spend from multiple addresses when they want to send Bitcoin to someone, e.g. for a withdraw.