It has long been understood that simple imprisonment does little to change a person's ways. While prison can be a deterrent for some, the reality is that things like addictions cause individuals to make poor decisions that result in imprisonment. Even if they would normally avoid doing dangerous things, addiction might push them to take part in criminal acts.
There are better ways to treat addiction than to put a person in prison or jail. Jails and prison are perfectly suited to those who might hurt others or continue to take part in criminal acts, but without treatment, those who are addicted are likely to be compelled by the addiction upon release.