"Drugs" is a very broad category.
That said, you can make a really general blanket statement that psychoactive compounds which give you a lot of pleasure are indirectly harmful to your health because you start neglecting all the things non-users do on a regular basis to keep themselves healthy and active.
So it's not so much how heroin causes damage itself to your body as it is how you stop bothering to eat or go outside because you already feel really good and have no motivation to do other things. And if you don't eat and don't exercise you start to waste away pretty badly to the point where trying to get off the substance will reveal how fucked up and self-crippled you've become. And this forms a vicious cycle in that you know it's killing you but shooting up will get rid of the feeling that you're really severely broken and dying.
It's similar to people in debt who opt to just waste money on something they want instead of holding back in a way that's only going to save them a tiny fraction of the money they actually need to dig themselves out of the hole they're in.