According to you What is correct ॐ Gam Ganapataye Namaha or ॐ Gan Ganapataye Namaha ?
‘m’ or ‘n’ sound comes with Anusvara.
like कं or कम् …. that is Anusvara.
Whether it should sound like ‘m’ or ‘n’ depends on what comes after it.
If anusvara is followed by guttural sounds i.e ka, kha, ga, gha or na, then the n sound comes.
So it should be pronounced as gun(g) like a bell sound…
kavi(m) (ka)vinam becomes kavi(n)kavinam
There are many such possibilities and so the sound changes accordingly.
Anusvara sounds change to m or n or gm or gg also.
These rules are given in sIksha texts… but there are many such texts based on the branch of Veda. There are more than 40 such texts… so it depends on which tradition you belong to.
Ofcourse in gam ganapataye , it is n …
Ways of pronunciation:
Om gan ganapatye namah
Om gam ganapatye naman
Om gung ganapatye namah
It is “Gam Ganapatayae namaha.” It is ‘Ga’ with Anusvara. The source of this mantra is Ganapati Atharvasheersha. Ganapathi is eulogised in Ganapati Atharvasheersha as Absolute Reality, the creator, the sustainer, the destroyer, the omnipotent, omnipresent and omniscient Parabrahma, the Absolute Self. ‘Gakaara’ is considered the unmanifest state, ‘Akaara’ is considered as the middle manifest state and the Anusvaara is considered as the final state of dissolution in other words Srusti, Stiti and Laya. The sound in general and the nasal sound represented by semi circle and a dot in particular, is the unifying factor. It is harmonious union in Peace.
Some of the information contained in this post requires additional references. Please edit to add citations to reliable sources that support the assertions made here. Unsourced material may be disputed or deleted.