Quote Originally Posted by Elin View Post
なんだ on its own can indeed mean "what" / "why" in casual language. But that's a different "なんだ” to the "なんだ" on the end of sentences, so it's best not to group them together in your head like that. When it comes at the end of a sentence like that, it's generally either a mild way of giving a reason / explanation for something, or stressing something. I think it's one of these things that is quite hard to explain the usage of beyond a simple definition like that, so it's best to just observe how Japanese people use it and try to mimic accordingly

An aside, but Japanese people quite often also use it as a get out clause if they start a sentence in plain form out of habit and then realise that the person they're speaking to is someone they have to be polite to, as you can end most plain form sentences with んです / のです / なんです and have them sound polite. :'D
That would explain why it was hard to find a post somewhere explaining fully the difference. Seems like I'll have to look for なんだ at the end of a sentence a pretty fair amount of times before I could use it myself. I'm probably going to have to drop comparing similar words(probably the wrong term to use I guess) to each other, it probably would help me a lot out and stop some confusions like that. I guess it could be an English habit or something.

You cleared my confusion up a lot better than most of the resources I tried to look at. I'm extremely grateful. The last bit of info will be nice to know, maybe soon I'll see it online somewhere although my reading skill are pretty bad so far(although it doesn't sound like it will be seen much online).