Intentions aside, the 67% recidivism rate in the US shows that it is more focused on recurring punishment than rehabilitation.
AKA (A, B, C, A, D, A, E) = 1 person out of 4 went back (25%). But, A went back 3 times so out of 7 stays 3 of them repeated (43%).
Yet another way of counting is to look at people at one point in time (C, A, D, A,). But, someone in prison regularly is much more likely to be in prison while your studying. This is mitigated by very long studies, but 10 or even 20 years is not enough.
PS: When you consider some homeless people use prison as a way to get free medical care it's easy for someone to be in and out a lot for minor reasons. Another group that's likely to come back are people who go to prison for failure to pay fines because prison tends to make you even more poor.