why?; what for? — a colloquial way to ask for a reason or cause.
なんで遅刻したの?
Why were you late?
彼が怒っているのはなんでだろう。
I wonder why he is angry.
試験を受けないなんて、なんで?
Not taking the exam — why?
how?; by what means? — used colloquially to ask about method or manner.
明日、なんで行くの?車?電車?
How will you go tomorrow? By car? By train?
この箱、なんで開けるの?ドライバーがいるの?
How are you going to open this box? Do you have a screwdriver?
この問題、なんで解くのが一番早い?
How is the quickest way to solve this problem?