The first sentence is correct. "Why did you go there" puts the subject (you) of the sentence in the past and the verbs (go and do) describe the actions of the subject (you) which was already described to be in the past. Technically if your friend was being consistent their argument would have been "Why did you went there and did that?" Which is very incorrect.
With "Why did you do that?", you're asking about the decisions and circumstances around that past event. Let's say you broke an ornament (which you hate) by accident, and your partner says "Why would you do that?", they're implying you did it on purpose. You might say "I didn't mean to, it was an accident!".
What's the difference between 'why would you do that' and 'why did you ...
"Why, I did what I did!" is a perfectly acceptable sentence. So, it's not just changing the words that can make it meaningful, it's also, as in this case, changing how the same words are presented.
Why I did what I did - English Language Learners Stack Exchange
Which one of these sentences is grammatically correct? Why did the writer use this word? Why does the writer use this word?
grammaticality - "why did he use" or "why does he use" - English ...
"Why you did that" is wrong merely because of the sentence structure. The other guy is right to correct it to "why did you do that". You must state the tenses clearly and somewhat early. It's like saying "He ran had before" when really it's "He had ran before."