Prison isn't the right idea. But getting them into some sort of treatment would make sense. And that could be court mandated for repeat offenders for some crimes.
Want to get rid of drug addicts? Start by banning all pharma ads and stopping over-prescription.
People don't go to their doctor and complain about pain for no reason.
Fools that don't learn from their own mistakes are bound to never-ending cycle of repetition. Individuals or whole societies, doesn't matter.