You don't. Hacks target the exchanges wallet by finding exploits and not the user accounts separately. If you want your funds to be safe, use exchanges for trading only and withdraw to your personal wallet.
this will be one of the safest ways that can be used. but if one exchange is hacked. can we get back the money we have deposited? I think some big exchanges will have exceptions about the missing funds. and maybe you can deposit the funds in a large and highly enriched exchange. because it is unlikely that the exchange will be crushed