In movies you always see two massive groups of people charging at each other and then it looks like chaos. How would two members of the same army avoid fighting each other?
Because the movie representation of a battle is incorrect. Armies would fight strictly in formation. Breaking with your formation would usually mean death since you'd be completely unsupported after that, and if your formation broke up then you're inviting slaughter for your entire side.
This question gets answered a lot: check this thread while you wait for more answers.