If we are talking about exchanges, who really works with market - they has no risk with leverage. If the trade loses - they close his position. If the trader wins - they don`t pay their own money - they get it from the market. But if some exchange make fake deals with their own money - you are right and they can lose all their money. But mostly in such situation we here that this exchange is "bankrupt" or, if we are talking about cryptocurrency exchanges - "the hackers steal the money".
Do you remember Terra Luna collapse? Exchanges hold some reserves of every listed coin. These coins were very popular and exchanges lost millions of dollars after its collapse. So, this is not a zero risk business.
Let's talk about leverage too. If trader loses, they close their position as you said it well, that's really risk-free but when trader wins, exchanges have to pay their own money as far as I know because not every trading pair has 3rd party liquidity provider.
It is true, that exchanges has their cryptocurrencies reserves, but Luna scam doesn`t means that exchanges lost their money due to their operations. It is like earthquake - you lose something, but it doesn`t depends on your actions. About leverage - the situation is the same. The exchange wants to maximize their profit with adding trading pairs that they don`t plan to trade on the market. So in this situation they become trader. If they work as they must - they have no risks with their activities.