These horrific conditions were the backdrop to my conversation with Mr. Kennard. He knew if he was resentenced to life with parole, a better sentence, he would be transferred to a lower-security prison, which meant housing in an open dorm as opposed to cells. Those can be the most chaotic housing units, where stabbings and homicides have been common . Maybe I could ask the judge to order that he be allowed to stay in Donaldson’s Faith Dorm instead, my client said timidly.

It is both absurd and tragic that the promise of a better sentence meant a 58-year-old man who has not received a prison disciplinary infraction in 15 years was calculating how to stay safe now that the possibility of freedom was before him. And yet, that is what Alabama’s addiction to incarceration and unwillingness to pay for it has wrought.

This crisis is fueled in part by the state’s Habitual Felony Offender Act, which allows a life sentence for numerous crimes other than homicide, including robbery and burglary if a defendant has had three felony convictions even for relatively minor offenses. (Mr. Kennard had previously pleaded guilty to three counts of second-degree burglary.)

Repeat offenders are the target. However, it has become increasingly clear that the greatest repeat offender is the state itself.

Back in 1975, a federal judge, Frank M. Johnson, found “massive unconstitutional infirmities which plague Alabama’s prisons.” Since then, there have been class-action lawsuits that ended in federal intervention at the state’s women’s prison, Tutwiler Prison, where inmates were being sexually assaulted by staff members, and at Limestone Correctional Facility, where prisoners with H.I.V. were dying at excessive rates.

In 2017, the state entered into another federal settlement agreement over violent conditions at St. Clair Correctional Facility, following a lawsuit by the Equal Justice Initiative. Most recently, another federal judge, Myron Thompson, ordered improvements in the prison system’s “horrendously inadequate” mental health care.

All along the way, Alabama has shelled out millions of dollars in legal fees to private lawyers to defend itself in these cases.