That's why you use mixers. Good mixers will completely break the chain between inputs and outputs.
Why are mixers legal? The only purpose I find on them is to money launder. They are literally useless if you don't have anything to hide.
Why are privacy coins like Monero legal? They are even more suitable for money laundering than Bitcoin. Privacy is on of the basis human rights.