What was wrong with my chick?

In my last hatch one chick was born with something wrong with it. It took longer to get up and walk than the others, then we noticed it had something that looked like a red sack hang from its underside, between the legs near its vent. It actually seemed fine apart from that, but obviously something was really not right.

It didn't last long, it just kept getting weaker. The other chicks bullied and pecked it too. We put him out of his misery in the end, not long after it was born. I don;t have a picture unfortunately.

What happened? Did it hatch too early? What might have caused it? How could it be prevented?