1Why?, what for? — a casual, conversational way to ask for a reason or cause, roughly equivalent to どうして or なぜ.
なんで遅刻したの?
Why were you late?
彼が急に怒り出したのはなんでだろう。
I wonder why he suddenly got angry.
せっかくのチャンスなのに、なんで断ったの?
It was such a great chance — why did you turn it down?
2How?, by what means? — occasionally used colloquially to ask about the method or way of doing something, similar to どうやって.
明日、なんで行くの?車?電車?
How are you getting there tomorrow? By car? By train?
この箱、なんで開けるの?ドライバーが要る?
How do you open this box? Do you need a screwdriver?