Because these are made by Japanese nerds for other Japanese nerds, who have no social relationships, and the only reference point for social intercourse is school. Not that they had social relationships there either, but they saw others having them.
For a less cynical answer, it's just part of the culture for anime/manga/games. I'm sure some researcher or journalist could delve deeper for some sociopsychological reason (and maybe has), but on the face of it, it's just what they do.