What is the justification for the typical punishment of a student who did not cheat but helped others cheat? Imagine this scenario: you're in an exam. Somebody asks for your help to answer a question. You help them (whisper the answer, slip them a note, whatever). You get caught. You get punished.

That's fine. You're not allowed to help others cheat. You broke the rules. The university is liable to punish you. All of this makes perfect sense so far.

But.

In my experience, it is often the case that this student who, remember, did not cheat on their own exam, often receives a punishment directly related to that exam, i.e. they fail the exam. 

This does not seem to make any sense at all. The wrongdoing of the student has nothing to do with their performance on the exam. They did not cheat. Therefore, their exam is a separate thing entirely, and punishing them by failing them seems like an arbitrary thing to do.

Let me give you an example. Say a student punches a teacher. Would this student ever receive a punishment like "oh now you have failed your exam in Abstract Algebra!"? 

No. The punishent will be general (suspension, etc), but the exams are not touched.

So, in the above example, why is the student who helped others cheat being punished on their exam, when their exam performance involved no cheating at all? What is the justification for this?
Probably the main issue that makes this policy logical is that when two students are caught communicating during an exam, there is no foolproof way for the instructor to tell who copied from whom. The communication may have been one-sided, or it may have been two-sided, or it may have been one-sided but in the opposite direction than what the instructor suspects. Thus, by the mere act of exchanging information with another student, in any direction, the student undermines trust in the value of their own exam as an indication of their knowledge. Giving them a failing grade is the only policy that guarantees that they will not get away with getting illicitly-earned points. Since as you yourself said, some form of punishment is definitely logical, giving that specific punishment becomes logical both as a deterrent and as a defense against a student getting away with copying.

In other words, the policy makes perfect sense, and is pretty much the only rational way for universities to address cheating on exams.