Ok, wall of text, so take your time to read.
First, these shows are aimed at teens. Since our society delegates the act of teaching children mostly to women (changing, but still), we have that the teacher is the grown female outside the teenager family circle that said teenager have the longest contact with.
In anime/manga this romantic/sexual tension is explored in several titles, like Onegai Sensei, KissXsis, and others.
So we can infer that several teenager boys have the hots for the teacher. Teenage girls ALSO have the hots for the male teacher, but I will restrain the answer to the boys' universe.
One sub-genre of anime characters regarding teachers is the Sensei-chan:
A common Japanese media character type, the female high school teacher who is fairly young, attractive, even cute, and on friendly terms with her students.
On the other hand, she is still unmarried, and very conscious about it, as well as about the lack of respect she gets.
Then we get another genre of anime characters, the Token Mini Moe:
The Token Mini Moe is a young or young-looking member of a cast designed to appeal to one of two predominant demographics. The first is those who simply find the character absolutely adorable and/or endearing and feel protective towards him or her. The character allows this sort of fan to act as and live out the role as an idealized older brother or sister (or parent) cheering their little sister on and helping her achieve whatever goals the setting deems important. The second are the Lolicons/Shotacons, who take an erotic or romantic interest in the character. Needless to say, these two groups are often at each other's throats over the character.
When the two (Sensei-chan and Token Mini-Moe) overlap, you get the kind of teacher you are asking about.
So it is a character designed to fill two roles at the same time. Depending on the needs, the Loli Teacher can appeal more to the Moe side or the Lolicon side