Barn Stall/Animal Question

We've built a barn in preparation for whenever in the future we'll be able to buy livestock....and it has raised some questions.
I've heard animals can get a bad temper and kill other farm animals/flip food troughs, is this true? How do you prevent it?
Second question, how do we keep animals in the barn stalls if there's nothing to block the doorways/no gate? (What's the point of a stall with no gate? >___>)

I've heard animals can get a bad temper and kill other farm animals/flip food troughs, is this true? How do you prevent it?
Second question, how do we keep animals in the barn stalls if there's nothing to block the doorways/no gate? (What's the point of a stall with no gate? >___>)