The original definition of a "Class M planet" referred to "Earth-Mars" conditions.
This web page (which is not necessarily definitive) quotes the original Star Trek pitch from 1964:
IV. Nature and duration of command:
Galaxy exploration and Class M investigation: 5 years
VII. Consistent with the equipment and limitations of your cruiser class vessel, you will confine your landings and contacts to planets approximating earth-Mars conditions, life, and social orders.
It's quite possible that the 'M' originally stood for "Mars". ("Class E" might have been too easily confused with the word "classy", but that's sheer speculation on my part.) The Wikipedia Class M planet article suggests that the "M" is from the Vulcan "Minshara", but that's a much later invention, from the "Star Trek: Enterprise" episode Strange New World.
Remember that this was written in early 1964, when much less was known about the actual conditions on the surface of Mars. Quoting the Wikipedia article:
Until the first successful Mars flyby in 1965 by Mariner 4, many
speculated about the presence of liquid water on the planet's surface.
This was based on observed periodic variations in light and dark
patches, particularly in the polar latitudes, which appeared to be
seas and continents; long, dark striations were interpreted by some as
irrigation channels for liquid water.
A "class M Planet" is one whose surface conditions are suitable for human life without a spacesuit or equivalent. At the time the term was invented, it was thought that both Earth and Mars were class M planets. With closer examination of Mars starting about a year later in 1965, we now know that Earth is the only class M planet in our Solar System.