Translation should be ‘Why did you do this to my friend?’ ???
“Mój przyjacielu” here is the vocative form. Vocative is a rarely used case whose purpose is addressing other people. So a child calling their mom would usually use the vocative form “mamo!”, same for an interjection like “my friend” here.
For many nouns, the vocative form is the same as the nominative case. One example is the expression “Panie i panowie!” (“Ladies and gentlemen”), which technically is in the vocative case, but looks just like it would in the nominative. Some people say the vocative case will become completely obsolete in the next few decades, just as it did in Russian quite a long time ago.
In fact, the sentence here lacks a comma, which should appear before the form of address: “Dlaczego to zrobiłeś, mój przyjacielu?”. I suppose that if it was there, you wouldn’t have any problems deciphering the actual meaning. If you wanted to say “Why did you do this to my friend?”, you’d have to use the dative form: “Dlaczego to zrobiłeś mojemu przyjacielowi?”
Here’s an explainer on the vocative case: http://mowicpopolsku.com/polish-grammar/cases/vocative/
Thanks for clearing this up. I must confess, I’ve not spent much time studying the vocative case yet. I know sometimes dative masculine nouns can end in -u but the pronoun before it wasn’t dative, so it didn’t make sense either. Google Translate suggested it should be ‘… to my friend’. The sentence also now makes much more sense, simply knowing that a comma is missing.
Interesting comments, that the vocative may become obsolete. A Polish tutor once asked me,
‘Alex, how many cases are there in Polish?’
‘Seven’, I replied.
‘No there are six’, she replied and then read out all the names of the cases, except the vocative.
‘What about Wołacz?’, I asked
‘Yes,’ she replied ‘but we don’t count that one!’