What is the difference between this use, and "なに"

What is the difference between this use, and “なに”

I guess なに turns into なん whenever the next word is です
なにです would sound really weird, while なんです sounds “normal”.

That´s the best explanation I can think of right now.

There are some “rules”, but Paul’s approach about what sounds “normal” & “weird” is the best way to go. After a while you will “naturally” come to know when to use each, rather than thinking about some specific ‘rule’ long forgotten.

Edit: ah, the link won’t work, so I’ll post this excerpt instead:
1.If 「何 - なん/ なに」 is followed by 「と」、「だ」、「で」、「の」「です」, then「なん」 is used.

2.When you express quantifiers, e.g なんぼん、なんびき

3.When 「何 - なん/ なに」 is followed by 「も」、「が」、「を」, then「なに」 is used.

何なのだ(なになのだ) → なんなのだ → なんなんだ (What’s that?)
鳥なんだろうか、それとも飛行機なんだろうか? (Is it a bird or a plane?)