The cost of keeping people in prison is equivalent to sending your kid to an ivy league school. The budget is only so big, so they have to figure out who to keep and who to let go. Probably, 90% of the people in prison really need to be there because they represent a danger to society. In this case, some of them who should not be released are going to be released.
Now, as for the budget, if the DOJ says you have provide sex change surgery and God knows what else, it is going to greatly increase the medical cost of the prison population, that is draining the fund required for providing meals and basic requirements. Therefore, part of the budget problem is political. Another thing is the “death” penalty. If the guy lives twenty or thirty years before it is caried out, he is part of the problem of not being able to keep really bad actors in prison. A lot of the problems could be solved if there was any political will to do so. There isn’t.