Particularly with drugs like meth, which can be manufactured clandestinely by people who don't understand chemistry well, there are a lot of intermediates or potential reaction byproducts which are orders of magnitude more cardiotoxic or otherwise more harmful than pure methamphetamine. And that's before you get into the potential toxicity of any intentionally-added cutting agents.
I think ketamine synthesis is more involved, so it's likely that illegally manufactured ketamine is comparatively cleaner than illegally manufactured meth, but illicit ketamine is still probably harder on your body than pharmaceutical grade for the same reasons.
Illegal drug manufacturers have a moderate economic pressure to increase purity, but - short of not immediately killing users and losing your customer base - they have little economic incentive to ensure that the impurities that remain in the final product are safe or inert.
Yes, 500mgs of meth a day is almost certainly not good for your health. But these studies are usually not able to control for purity of the meth that is consumed, so I expect for these studies finding adverse effects of chronic use - at least some portion of this effect size is a result of purity issues rather than purely based on dosage.