The only thing prison does is keep the general public safe from convicted criminals for the period of their sentence and very little else despite you are told by the powers that be. If it did there wouldn't be so many return time after time to H.M UNIVERSITY OF CRIME.
Truth is, some people are just wired differently, also it can be to do with the way they've been brought up, their natural surroundings (ie: a lawless country compared to ours), drink/drug abuse, gang culture, some are just generally thick all round, and for others it will be a heat of the moment crime. No doubt greed and jealousy plays a big part too.
Then you slowly move over to self defence, which still has to be proven, even more so if the person who committed the act has previous form themselves. Just because you committed 10 similar crimes before, doesn't automatically make you immediately guilty of an 11th even if it does seem highly likely, hence the reason you're not supposed to divulge any previous crimes to a jury to stop any bias.
The other thing as well which can be hugely influential is trial by media, if the newspapers don't like you or have made up the jurors mind before a case has even gone to court then you are well and truly fucked.
Prison itself now has the problem of actually bringing some of the scummiest wankers in the UK together in the same environment, so this creates another gang culture inside that's worse than the ones outside. Not just the UK obviously, that's a worldwide problem.
Some people are career criminals though and either can't or won't change. I do think that the most savage ones that are overwhelmingly found guilty don't deserve food, a roof, and all forms of care at our expense and should be terminated.
The alternative of course is keep your head down, study, get a job, and be nice to people. Simple.