We learn these rules in school, although the degree to which students care varies.
But, I was deprogrammed of my prejudice in University linguistics courses (highly recommend). What I learned is that speech is primary and it comes in many varieties (aka dialects) with different rules, and because textual communication has become the norm, we increasingly see these written.
It's a mistake to assume that a construction is ungrammatical just because it doesn't follow the rules of prestige English. Of course other varieties have subtly different rules. Many don't ever use "whom", for example, and it would be eyebrow-raising if you did. You can think of it as register or code switching, if it helps.
Similarly, orthography is just orthography, secondary to speech. It's a mistake to think that because someone wrote "should of," that they must not know the difference between "of" and "have". (In fact, that this orthographical error is virtually always made by a native speaker is some kind of signal.) Substandard for professional writing perhaps but that's all it is.
Schools, with few exceptions, try to get everyone speaking and writing in prestige English. We generally don't appreciate variety and fail to see the parallels with, say, snuffing out foreign languages.
I've since made the observation that it's curious that loving English almost always takes the form of being pedantic about prestige conventions and not instead enjoying the different flavors and their histories.