A few things. My girlfriend is a prison nurse, and a good friend's brother is a CO at another prison.
1. The population of guards is pretty bad. The job pays approximately $shit, (Good overtime possibilities, though) and the staff's quality suffers as a result. Frequently, you end up with criminals guarding the criminals. Said guards are often compromised and either become indifferent to criminal behavior or actively aid it.
2. Female guards perform poorly compared to male guards. This is due to a variety of things, but the biggest reason is that inmates are much more willing to test female guards. "Testing" involves intimidation, trying to bribe them, seducing them, harassing them, etc. A male guard commands a certain amount of respect simply by existing that a female guard does not get. My friend's brother summarizes it by saying, "A male guard can point to the rules and say, "Sorry, just doing my job," and an inmate will understand that it's the Man keeping him down and not the man. A female guard, because she's perceived as weaker, doesn't get that ability. Prisoners think they can get away with it because the woman isn't going to enforce the rules." From this, he asserts that the ideal male guard is an unthinking robot. "Sorry, you have violated Rule 21. I have to write you up. No exceptions." Meanwhile, an ideal female guard is a "crazy, man-hating, psychotic bitch" who takes sadistic pleasure in making prisoners' lives hell. She won't get any respect otherwise.
Due to most women being decent human beings, this leads to even higher rates of women being compromised compared to men. Whether it's from being intimidated or seduced, women end up giving favors, fucking inmates, or turning a blind eye to drug activity, rape, and violence. Men do it too, (see the "criminals guarding criminals" section) but at lower rates.
3. Due to a variety of factors, including too many prisoners, not enough for them to do, and a pervasive atmosphere of the animals running the zoo, drama is the primary occupation of most of the inmates. After all, they have nothing better to do. So they make excitement. They fuck with guards, fuck with each other, gamble, (which leads to fucking with each other because debts are created) rape each other, try to seduce the female guards, harass the medical staff, do drugs, make bullshit accusations against the prison just because they can, and so on. To counter this, prison staff frequently collaborate with the gang bosses. They tell the gang boss, "Hey, Jerry's being a pain. Can you take care of him for us?" Jerry gets his ass kicked, and the problem goes away. In return, the prison turns a blind eye to the things that the gang boss is doing. This, of course, leads to prison-sanctioned violence and rape.
Fixing this requires a hard look at what we use our prison system for. I think that we use it for far too much. We shouldn't be sentencing minor drug offenders and petty criminals to prison; it overloads the system and turns the place into a teeming madhouse where the prison staff is focused on survival, not actually rehabilitating the inmates.
In combination with this, we need to get better quality guards. Currently, corrections officers are frequently the failures who couldn't become cops. We need to change that by offering competitive pay. Doing this requires the prison system to shrink and become a smaller organization. Prisons should be focused facilities rather than being a Walmart.
Finally, I'd also suggest segregating prisons by race, but all the hippie Integration Uber Alles people would whine about it.