It is because so many inmates in our state and federal prisons were molested as children, which continues the cycle of broken lives and childhoods filled with trauma that so many generations of their own family members have suffered through.
Child molesters are targeted because it is a way for victims in prison to lash out at their own molesters. They feel like they can confront a child molester on equal terms now instead of as powerless children. Plus most inmates are parents themselves and feel like they can exact some vengeance for the children those men and women hurt.
In general, child molesters are hated. There will be occasions when gangs or hits could be involved, but inmates mostly attack molesters for extremely personal reasons.