It is called '비음화'.
(It is slang so it is not grammatically right but it follows grammar.)
'비음화' means to become(=화) a nasal(=비음).
ㅁ, ㄴ, ㅇ are nasal in Korean.
ㄴ is already a nasal so it is technically not 비음화 but it makes sense.
ㄴis changed to ㅇ because ㅇand ㄱ sound by the same vocal organs.(they are called velar/soft palatal consonant.)
So it is for the convenience of pronunciation.