One reason drugs are dangerous is because when you're high, you don't think straight. So things like safe sex and condoms are not on your mind.
The way HIV is spread with drug use is that blood is drawn up into the syringe to mix with the drug so it can be shared more equally; the infected drug is then injected directly into the recipient's veins.