You see in the movies they run at each other, and more or less intermingle. Though this does not seem right when considering lines they were drawn up in. Is it more likely that the first few ranks of each formation fought each other while the ranks in the rear waited for their comrades to die and they could move up? I guess I'm referring to the Roman/Greek/Persian/Carthaginian sort of battles and not the Celtic armies who, from what I understand, were less organised.
Always more to be said on this question, but you may be interested in some of these older answers from u/iphikrates:
https://www.reddit.com/r/AskHistorians/comments/48pumt/did_the_people_in_the_front_lines_of_ancient/