B has done something bad that A hadn't ever expected B to do so A is asking B
1- A: Why would you do that? I don't understand.
2- A: Why would have you done that? I don't understand.
What is the difference between these two options?
Why would you do that? is a question in the present tense. And by convention the present tense is used for reasoning in general, so it might be applied to the past.
Why would have you done that? inquires specifically about the reasoning and conditions that may have affected your mood about doing something in the past (which may or may not have happened, or been done by you).
People are not always this deliberate. But not only does the second question ask after the past, the change in word order subtly reorients the interrogator in terms of skepticism. Consider the difference:
Me: I once boxed a jellyfish while skydiving.
Gullible Niece: You have done that?
Storyteller: I once arm wrestled a kangaroo.
My Slightly Older, Wiser Niece: Have you done that?
In the first case, I can probably keep telling her ridiculous nonsense. In the second case, the jig is probably up and it's time to find something more interesting to do.
Implication: A person would do something if something else happened.
Formal grammar pairs would with simple past** or was/were:
It is hypothetical, it hasn't happened. It is spoken in the present about something that has not occurred.
That is for something that has already happened. Past conditional tense.
I would have done it if I could.
Firstly the second sentence needs rearranging:
Why would you have done that? I don't understand.
The sentence:
Why would you do that? I don't understand.
This sentence asks why B would do something, and sort implies that B would do it again, as though it were a part of who he is. It's much more direct, i.e., directed at B as a person.
Why would you have done that? I don't understand.
This sentence places the emphasis in the past, at the time when B did the thing. It expresses curiosity and a desire to understand with regards to what B was experiencing at that time, and urges B to investigate not so much himself, but what he was experiencing at the time, or what might have influenced him to do such a thing at that time.