The biggest barrier in prison to effectively rehabilitating criminals is, other criminals.
Peer pressure is extremely powerful, and even the strong of character(which very few criminals are) will be led into a certain mindset.
Locking up bad persons alongside worse ones in a large warehouse presents an almost insurmountable barrier to rehabilitation, but its cheaper than addressing each one, having far more jails with far fewer offenders.
The public are not in the slightest interested in rehabilitation, except when it comes to the time fo release, and no politician is likely to win votes by spending lots of money on criminals.
It’s a matters of any closed society, such as the armed forces, residential schools, and such that it produces a type of behaviour which amplifies minor issues in ther subjects own head, paranoia is quite common, but amongst prisoners who are often of limited mental capacity and with every reason to believe the system is against them, its far greater, and that’s when the peer pressure is at its most effective.
There was an early Victorian viewpoint that held that criminals made up a class of their own, and if you could incarcerate and isolate them, crime would dissappear.
So we in the UK hanged them for what we’d call fairly minor crimes, and transported them for even lesser ones - it didn’t work.
There is the easy view that we should simply build more and more jails and just lcok them up for as long as possible, or even longer, but what we would actually do, especially is you add in zero tolerance, is create a gulag type of system, where entire demographics would be locked away.(obviously the word gulag has some nasty connotations, but here I mean incarceration of significant numbers on an industrial scale)
By the time a criminal has reached the part of the system where they meet people such as myself, its already a long was too late, they have been in offending mode for most of their lives, from 12 years upwards usual.