How do "civilized" nations prevent rape and physical abuse in prisons? Guards cannot monitor all prisoners all the time, they cannot always get there quickly enough if someone happens to notice something on camera.
Life is rarely all or nothing. Prison systems can
diminish abuse among inmates by avoiding over-crowding, avoiding prison designs where cells are down blind corridors and fairly unmonitored, diminish corruption among correctional officers, etc.
Or are you attempting to hold up the many jails and prisons as the epitome of sensible design? No. Improvements upon designs and sentencing can and should be made.
As it stands, much of the large prisons and jails in the USA and elsewhere are forums for mind wrenching and physical punishment. This not only leads to criminal and immoral abuse within but intensifies the ills in society as most of these people will be released back into the wider society. After having often been further broken in prison they will often not adjust to behaviour of what is necessary to remain outside, but retain what they learnt upon the inside.
Relatively uncivilised societies will not only relish in the extreme abuse among inmates as a form of vengeful punishment, but are too dim to acknowledge and rectify the greater ills and costs of such immorality.
On the points of mental illness, society should begin to end use of the prison system as a warehouse for the mentally ill. Increased numbers psychiatric bed space in the medical system of communities is a necessity. A large reason why there are often more visible homelessness in city such as Vancouver and Victoria in comparison to Seattle and Portland are that much of such homelessness is due to mental illness, but many of those who are afflicted in the USA find themselves to be interned within the prison and jail systems. All around, to diagnose and treat, regions require greater attention and support for community care of mental illness.
Though certainly not all those with criminal tendencies have a diagnosable mental illness. Mentally, many such criminals are damaged and broken due to the sorry states of prisons and jails.
Short term blood lust often drives this and the lack of sense propagates the extensive costs. Grow up, and mature as a society to diminish its current ills.