ralated to this topic Can I withdraw Ether from exchanges to a contract wallet? I have a question that how exchange understand which address is a contract and how doesn't pay gas more than 21000...?
This is internal exchange business logic, so we can only guess.
As I see it there are two options:
Exchange tries to detect whether the receiving address is a contract or not. As they don't have to do it on-chain they can just check whether there is code at the address or not.
Exchange doesn't try to check anything. The transaction simply fails if the transaction requires more gas than was provided. The exchange may or may not give a higher gas limit to the transaction.