Note that self-defence is a
defense, not a
justification. It doesn't stop you from being taken to court, because you still
were involved in something the law considers a crime. Your actions being self-defence just mean that the judge will likely find that there is
reasonable doubt whether you were, in fact, committing murder. You might still have been committing murder! You might have set the other guy up to attack you so you could kill him, like with the old custom of professional "hired gun" duelists. But, since the other guy
did attacked you first, it's (usually) impossible to
prove that that's why you did it, rather than it just being because you were, in fact, trying to save your own life. (Unless you left written documentation of your nefarious plots somewhere.)
Fun fact: this is also true of "Fair Use" in copyright suits—it's also a defence, not a justification. If you put a 30-second sample of someone else's song in your song, they can still sue you, and waste your time and money in court! They just probably won't win, in the end. But if they have a lot more money than you, you might plea anyway.