adverb
why?; what for?
Casual interrogative asking for a reason or purpose. Often used in spoken Japanese and informal writing.
なんで遅れたの?
Why were you late?
なんでそんなことしたの?
What did you do that for?
adverb
how?; by what means?
Casual interrogative asking about method or means. Less common than the 'why' sense; どうやって is often preferred for 'how'.
なんでここまで来たの?
How did you get here?
なんでそんなに早く終わったの?
How did you finish so quickly?