On the internet, there tend to be more grammar sticklers. They're masked behind anonymity, so they can lash out at people for simple reasons, like bad grammar with few repercussions to themselves. Because of this, people who spend a lot of time on forums, message boards, or the like, tend to get better grammar, or at least spend more time looking over posts before submitting them.
In school, there's a lot less challenge to do well. The teachers can sometimes care less about you having good skills and more about you getting a good grade. They think that a few mistakes are just fine and completely normal. You pick up on that over the years of being in school, so you tend to care less about the assigned writing.
The last point I want to bring up is that topics in school rarely are of any interest to you. You'll do the minimum to get a good grade, and just not care about the assignment. In contrast, your posts on the internet tend to be about topics that are of interest to you, so you take more time to think about your response and make it as legitimate as possible. Good grammar, intelligent ideas, entertaining, etc... For example, some of the fandom posts for things like Doctor Who or Homestuck can go on for pages, whereas some assignments for school are turned in with a page of content and very little effort put into it.