In what cases does this happen and how to avoid it ?
You avoid this to reducing usage of such centralized exchanges. There are a number of alternatives that won't ask for KYC or source of funds in case you are trying to make a trade or swap. It doesn't matter how careful or perfect you are, once you keep using a centralized exchange for your daily transactions. At one point, they will flag one of your transactions and ask for the source of funds, and you will be forced to obey their orders if you want your money back.