Well if it's an urban fantasy like say Bleach or SAO then it's not that hard to explain. They have to go to school because they have to.
And if it's high fantasy like most isekai/battle harem kids go to school to be magicians/warriors. For eg-Naruto, Black Clover, etc...
Although there are things like My Hero Academia where neither the school nor the hero profession makes sense (Heroes are nothing more than costumed cops yet there are also cops and they don't have the authority of cops and yet they have to attend special school.) Well that should be expected from shit that's made to pander to the capeshit fad.