I was one of the researchers in the well-known Stanford prison experiment in 1971, demonstrating the destructive dynamics that are generated when one group of people — randomly assigned as “guards” — is given near-total power over a group of “prisoners.” In six short days, inside a simulated prison environment, authoritarian forms of mistreatment emerged and numerous emotional breakdowns ensued among otherwise psychologically healthy college student volunteers. In the decades since, I have studied these dynamics in real correctional settings: jails, prisons and immigration detention centers throughout the United States.

Among the things I have learned is that the damaging dynamics unleashed inside such places are not self-correcting. Quite the opposite. Absent transparency and accountability, dehumanization and degradation intensify. Indeed, if left unchecked, the destructive forces that are set in motion almost invariably lead to greater and greater levels of mistreatment.

Because they make up what Justice Anthony Kennedy years ago called a “hidden world of punishment,” what goes on inside these facilities largely escapes public awareness and scrutiny. Many of these sites operate outside the conventional bounds of the rule of law. Lawless institutions in particular do not merely tolerate mistreatment: They engender, normalize and amplify it.

A recent HBO documentary, “The Alabama Solution,” dramatically illustrates many of these forces at work. Based on a six-year investigation and contraband cellphone footage that courageous incarcerated men supplied from inside one of America’s most dangerous and dysfunctional prison systems, filmmakers Andrew Jarecki and Charlotte Kaufman give their audience a gut-wrenching view of something that few outsiders ever see: that hidden world of punishment laid bare, vividly depicting the depth of institutional cruelty and indifference to suffering that characterize many of our nation’s penal facilities.

I wish I could say that the egregious conditions and shocking treatment depicted in the film were limited to just one prison or prison system. The truth is that, although Alabama may be an outlier in some respects, scenes like those depicted in the film play out all too often in jails, prisons and detention facilities across the country. There are currently nearly 2 million people confined inside the nation’s bloated carceral system, which costs taxpayers more than $180 billion annually to maintain. Yet in far too many of these places — operating away from public view and meaningful legal regulation — callousness, cruelty and mistreatment prevail instead of rehabilitation, programming and treatment. Far too many people emerge from them traumatized by the experience, if they are fortunate enough to emerge at all.

Rather than reforming these institutions and minimizing their reach, federal and state govern­ments are expanding their dehumanizing penal practices beyond the prison walls. We are daily witnessing the metastasizing of an increasingly lawless system of state-sanctioned oppression in society at large, one in which anonymous government actors operate unrestrained by due process safeguards, subjugating and terrorizing people with impunity — as has long been common inside prisons and jails. Only the restoration of transparency and the rule of law can reverse the perilous direction in which our country has been moving and shift the tide back toward justice and humanity.