There's quite a bit of evidence that many repeat offenders actually have pre-existing brain trauma. citation:
https://www.telegraph.co.uk/science/2018/02/26/60-per-cent-prisoners-have-head-injuries-experts-warn-brain/60% of inmates have brain damage. Let that sink in. "rehabilitation" is based on the same worldview that says we should punish them: it views the problem as people being fundamentally healthy but morally wayward: the harsh view is that punishment is deserved, and that punishment will deter crime, and the compassionate view is that they're "misguided youth" who just need some social / moral guidance from well-meaning organizations and individuals.
The alternate viewpoint, which has a fair amount of evidence, but isn't the view pushed by either the liberal or conservative mainstream is that "most people in prison are actually mentally ill or have visible brain trauma". No amount of social conditioning or threats of punishment are going to change behavior, which is because of brain damage or under-treated mental illness.
Another one I read about once, was some researchers back in the 60s or 70s who cross-referenced childhood brain damage and childhood abuse (all types of abuse) among young kids (~12 y/o) who'd been in trouble with the police, then looked at later violent offending. Having
either brain damage or child abuse upped the chances of violent offending by e.g. 10% extra. i.e. not that much. However, brain damage
plus child abuse upped the chances of violent offending by a whopping 16 times (as in 1500% more).
So, in other words there are several things that can go wrong, any one of them is fairly easy to recover from, but when they get stacked together, they become exponentially harder for people to recover from, leading them to problem behavior. e.g. I've mentioned
lead poisoning before, which causes brain damage and violent behavior. Think about the two factors above of visible brain trauma and child abuse, which stack to a "times 16" level of violent behavior compared to having only one risk factor, then multiply on on top of that exposure to heavy inner-city lead levels up until the 1970s, and you can understand why violent crime rates were so high. Some people had the lead exposure, some people had brain damage, some people had abusive childhoods, and some people have 2-3 of those things at once.