There are basically three different situations where this applies:
A) Adult has sex with a minor under the age of consent: this is illegal for obvious reasons, so it doesn't matter how willing the minor is, he legally cannot give consent.
B) Adult has sex with minor over the age of consent: this might be legal, but it takes on a predatory tone as the position of authority over the minor (along with the adult/minor age difference) puts severe pressure on the student to do as the teacher says. This can easily lead to coerced consent. It may also be against the local law or the local school regulations.
C) Adult has sex with another adult: here you also have the coerced consent thing, but it's not as severe as the previous case. However, it can also be against local laws or school regulations.
Basically, the crux of the matter is coerced consent. While the student might be giving consent, the situation surrounding the relationship might be such that significant pressure is put on the student to give such consent. For example, if I'm a student and a teacher makes a pass at me, I will feel at a tremendous disadvantage, as the teacher can "get back at me" for my rejection by destroying my grade in perfectly justifiable ways, and if I try to levy a case of sexual harassment, it's likely that the school administration will side with the teacher when there is an absence of evidence, since students are notoriously immature, petty, mischievous and clearly not above fabricating such accusations for their own ends. And likewise, teachers are known by the school staff as respectable, trustworthy, level-headed and professional, so it takes very solid evidence to convince them otherwise. So if I, the student, knows this, when the teacher makes a pass at me, I have to choose between getting my grades destroyed (and potentially losing things like scholarships or getting into the college/grad school/etc they want, which in turn will end up shaping the rest of their lives) or having sex with them. That is coerced consent. I might end up giving consent, but it was similar to the consent I might give with a gun pointed at my head.
So when the school administration finds out about a student-teacher affair, even if the student wildly denies accusations of coercion, this pressure still exists, and the school administration just can't be sure. It's best to make blanket statements that forbid such relationships than doing extensive and awkward investigations to rule out coercion (which is not as easy as it sounds).