I agree with you. Gratuitous punishment for no other purpose than to cause suffering is a religious concept. That's hell in a nutshell. Rather than simply let the sinner cease to exist, or exist in a place like he did in life, one is deliberately kept conscious for eternity just to make him scream to no benefit to anybody that is not a sadist. And that kind of thinking translates into making prisons as hellish as possible in the eyes of some.
Prison should remove dangerous people from the streets for the benefit of the rest of society, not to punish them. Their incarceration should serve as a disincentive to them and others not to repeat the criminal action. And if prison rehabilitation ever becomes a thing, that would also be a good reason to lock somebody up. The loss of freedom, the loss of an income, and the social stigma of prison are de facto punishments - not because prisoners should be punished, but because the justifiable reasons for locking them up named above produce those effects. If we had secure islands to place them, I wouldn't want them caged.
But that's not how most people think. They have the religious model in mind, where violators are thought of like sinners, meaning they deserve to be hurt the way God would hurt them. If it's considered appropriate for a good god to do, then it is appropriate for civil authorities to do as well. Rape them. Give them AIDS. Strip them of their humanity and dignity. They deserve it, right, for sinning against the state.