No doubt many people who can’t afford housing lost their money to addiction, and giving them housing will not solve the addiction.
That being said: getting clean is way more likely in a stable living environment than in an unstable one.
I’d also add that homelessness can exacerbate an existing addiction. It’s a stressful and traumatic experience.
So yes, giving them housing will not solve addiction. Addiction is hard to overcome even for wealthy people with loving, supportive family.