> those who spend a lot of time in prison seem to come out worse and reoffend. How is that helpful?

You're implying that imprisonment makes people offend more - perhaps the simpler explanation is that most criminals will commit crimes when they get the chance, especially prolific criminals. Prison takes them off the streets and stops them victimising more people - this is helpful.