In the case you raise of count, this is simply Assimilation (phonology). It’s not that the m and the n are interchangeable, it’s that nt is easier to pronounce that mt, because both the n and the t are alveolar, so you do not have to move your tongue and lips between the two sounds; m and t on the other hand have different places of articulation.
A lot of sound change involves assimilation, since a lot of sound change is driven by ease of pronunciation; e.g. computare > compter > conter > count. The reverse change, Dissimilation, is rarer, and usually involves removing repetition of the identical sound, rather than making two different sounds less similar.