Most occurrences of the retroflex nasal in classical Sanskrit are not chosen by the speaker but produced by a rule. When certain retroflex or r-like sounds occur earlier in a word, a following dental nasal is converted to this retroflex one, even across intervening sounds, and the grammatical tradition states the conditions precisely, including which consonants block the change and which let it pass. The rule is one of the more remarkable pieces of the classical analysis, because it describes an effect operating at a distance rather than between neighbouring sounds, which is a kind of pattern most descriptions of language did not attempt for another two thousand years.
The consequence for a reader is that this letter carries information about what came before it. A retroflex nasal in a Sanskrit word implies a retroflex or an r earlier in the same word, and an editor reading a damaged inscription can sometimes use that to reconstruct a lost syllable. In the Prakrit of the edicts the picture is different and the sound occurs in its own right rather than only as the output of a rule, so the same letter means something rather less specific there.
The rule also has a limit that the tradition states carefully, and the limit is what makes it a rule rather than an observation. It operates within a word and not across the boundary between two, except in compounds, where the tradition specifies which kinds of compound count as one word for this purpose and which do not. Those specifications are among the more intricate parts of the classical grammar, and they are the reason the same two elements can show different nasals depending on how tightly they are joined.