What did you do that for?
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?
Why are you suddenly crying?
Why didn't you come to the meeting?
all sorts of things; anything and everything · by all means; at any cost