It's both the prisoner and the prisons fault.
The prison should've done what they could to safeguard vulnerable prisoners, if there is an active threat against another prisoner based on gender, race, sexuality etc then they have a duty and responsibility to act upon it. It's law and policy.
I get that it's not high school, and these are adults but all prisons DO have safeguarding measures in place to protect more vulnerable prisoners who may be more and susceptible to other prisoners who are in for more serious crimes like rape and murder. ESPECIALLY when there is a threat of harm against another prisoner simply for being gay
That's why there are separate wings for levels of crime and offenders, mental health prisoners are kept away from the general population, those who are vulnerable due to their sexuality and the way they present are also kept separate and etc etc