Why words having 'が' in between other letters pronounced as 'んが'？


I came across many cases where I found Japanese natives pronouncing some words
containing `が` or `ぎ` letter with others (Example: `かぎ`, `ちがいます`) as `んが` or
`んぎ`.

Are there any rules to do this in any particular context or something?

