I noticed that the word 単位 is written as たんい in hiragana, not たに. Is there a difference in the way んい and に are pronounced? If so, does the same principle go for んあ and な, んえ and ね, etc.?
There are three differences
たんい has three morae ("syllables"), where as たに has only two.
たんい has a uvular ("nasal") /ɴ/, i.e. [ta.ɴ.i], whereas たに has a "normal" /n/, i.e. [ta.ni].
たんい【HLL】 drops in pitch after the first mora, [たに]【LHL】 drops in pitch after the second mora.
Try to listen for all three differences, they're all important.
The sound and rhythm of んあ んう んえ んお are analogous. (Pitch, of course, depends on the word.)
However, in some cases (e.g. 反応 はんのう from はんおう or 天皇 or 銀杏), the "nasalization" has been lost "officially", so to speak. But /i/ following /ɴ/ it is usually preserved, 雰囲気 ふんいき, 原因 げんいん, 単位 たんい etc. That said, no one likes the combination /ɴ.i/, so these words are often subject to metathesis, see for example this answer.