If they customer money is safe, then who was the owner of the hacked money? Exchange own it?
Let's start with the beginning. When one transfers money into "his wallet" at an exchange, he actually has here a custodian wallet. That means that the exchange has the private keys, the exchange owns the money and displays how much would they give you if everything is OK and you do withdraw.
Most of the funds sent by customers end up in cold wallet. This happens because there are usually not many big withdrawals. The trades / operations the users make are only changing numbers in a database, not in the wallets.
For withdrawals the exchanges have their hot wallets. Those are a bit risky, those are usually hacked, that's why the exchanges try to keep a small percent of the funds there, just to have reasonable withdrawal times. That money is usually "insured" (for example Binance claims to have a separate fund for that; this fund is built from their earnings from the fees).
TL;DR; When you deposit you get an IOU (I-owe-you) amount in your account, not real money/BTC. The withdrawal is based on that IOU. Where the exchange gets that money for you is its own business. If they want to keep their customers, they have to stick to that value.