Teach in / teach on; class in / class on
Solution 1:
The Chicago Manual of Style does not include the word "teach" in their list of common problematic words and the correct preposition construed with them. It does include the verb "instill," and indicates that this verb is correctly used with the preposition "in."
More interesting, though, is the inclusion of the word "based." It indicates that the following adjective should be "on" when used preceding a premise, and "in" when used preceding a field of study.
With this guideline, I would assume that the preposition used should be selected to convey either a summary of the class subject ("on"), or an immersion in the class subject ("in"). For instance, I would take a class in standard deviations if I was pursuing a degree in mathematics and had already acquired any prerequisite credits. Or, I might take a class on carpet-laying at my local community college; the class subject is limited and does not imply a broader range of study.
It stands to reason that common use may default to prepositional accuracy without much conscious thought on the part of a speaker. The preposition is likely considered further in written communication to convey credibility.