I get it, it’s like the Hungarian szombat. Linguists call that pre-nasalization. In French, first the b was prenasalized with m, then the b was elided altogether, leaving only the m.
But what caused the nasal onset in the first place? This is something more common in certain Polynesian languages, like Fijian in which all the voiced stops are prenasalized. (e.g.: Fijian [b} is always pronounced /mb/, [d]is always pronounced /nd/.) I don’t know of any other examples of this in French.
In Arabic, [m] and [b} sometimes exchange places. Makkah was originally Bakkah (Psalms 84:6, Qur’ân 3:96).