When someone says in an attacking or aggressive or annoyed tone "why did you....?" this is not a search for information. Therefore the response we usually offer "because...." with an accompanying explanation will never suffice.
So the more effective response would be "I see that it bothered you. I am sorry for the pain/annoyance/inconvenience caused".
It is not about you but about the other person. So focus the spotlight on them.
In general it is important to remember that the vast majority of relationships we have in life are not about ourselves but the other person dealing with his or her issues through you. And we of course are more often than not dealing with our issues through others.
Mussar Haskel: Don't take things personally. It is not about you nor was it ever. [Note: I consider this one of the most important insights of my life. It has saved me from great anguish and despair and continues to do so.] There is a good way to check if this person is primarily concerned with you and your well being: Does he send you a present on your b-day? Does he call/text/email before Shabbos wishing you a good Shabbos? Or after Shabbos to find our how your Shabbos was? Does the person inquire about your financial situation in order to offer help if needed? Or your health and other types of well being? Does he daven for you? [If he doesn't know your full Hebrew name and your mother's then he probably doesn't]. Meaning, if the person is REALLY concerned with YOU it will not only be expressed in criticism but in positive, encouraging and loving ways as well.
That being said, if what the other person said can be used as a vehicle of self-improvement, then by all means - take it to heart.
I once heard a דבר חכמה from our former Pres. Clinton who said approx. as follows: Take criticism seriously, but not personally. If there is truth or merit in the criticism, try to learn from it. Otherwise, let it roll right off you. The problem is that most people take criticism personally but not seriously. So they just get offended but don't improve.