My recollection (and it's hard to find proof of this on the internet, I think we're going to have to dig up a pre-1970s published book on astronomy) is that at the time of TOS, "Class M" was the accepted designation for planets that are like Earth and Mars.
HERE'S THE IMPORTANT POINT: When the term was created, and when the TOS episodes were filmed, our best knowledge of Mars was based on Earth-bound telescopic observation. At that time, the scientific consensus was that there was a good chance that Mars could support life. In fact, the telescopic observations at the time noted shifting patterns of light/dark on on the Martian surface, and many scientists attributed this to seasonal patterns of plant growth.
The Marinar 9 mission in 1971 proved that assumption to be wrong. It was after that mission that we started to learn what we know to be true today: Mars is dry, and there are no obvious signs of life.
As a result of this knowledge, "Class M" was no longer an appropriate name for planets that might support life. The astronomical classifications were changed, and now we use the more accurate (and easier to understand) terms "Earthlike" or "Terrestrial."
Unfortunately, everything I've just said poses a problem for ST canon: we have episodes where characters are referring to planets using terms that are no longer in use. How to explain that?
Simple: create the new classification, and write in that the terms were developed in the 22nd Century.
The only real-world problem with this is (as I've experienced over the past 24 hours) that because of the popularity of sites like this, people who look for explanations of the term "Class M" do web searches. Search return rankings based on site popularity will drive sites like this to the top, and thus people will assume the information is true. (After all, why wouldn't we?)