The medical community recognizes addiction as a disease. It's not just a choice. It is a complex disorder involving both the mind and the body. It needs treatment.
This is why some court systems have special drug programs for low-level offenders who deal with addiction. If they get treatment for that addiction, they can sometimes avoid jail time and other serious consequences. The court recognizes that they have bigger issues and that curing them will do more to help them follow the law than penalizing them.