The original M’s actual name was revealed gradually in the books as Vice Admiral Sir Miles Messervy.
It seems likely it is an initial for his name, originally, as that was done by some actual people Ian Flemming knew in MI5 and MI6, including one head of MI5 Maxwell Knight who signed M.
According to John Pearson’s biography of Flemming, The Life of Ian Fleming, he also used M to refer to his own mother, which may either be part of it, or just share the general practice of referring to people with single letters.
(info from the Wikipedia page for M. ).
Mother itself is the code name for (NON-Marvel) The Avengers ’ handler in some later seasons of that spy show from the 1960’s. I imagine it could be a sly reference to M in Bond stories, as they did that sometimes, particularly later on.