Most people understand the difference between aggression and self-defense, but at times they need to be reminded with regard to a particular situation.
If you are in your house and someone enters it without an invitation and begins to steal or engage in violent acts, you have a right to defend yourself using force, up to and including killing the aggressor (in theory you aren't supposed to kill a thief unless they are also threatening, but most people won't second guess your feeling threatened).
If you are trespassing in someone else's house and they shoot at you and miss, you don't suddenly gain the right to self-defense. You have the right to run for your life or beg for mercy.
On the other hand, if a thief has surrendered and is no longer a threat, you have to wait for the police to arrive. You can't kill them legally, even though you could have just a few seconds before the surrendered.
Most people see the analogy to prisoners of war. The moment a soldier has surrendered, even if they were trying there best to kill you just a few moments earlier, they are protected under law. Killing them becomes a war crime. In the heat of battle this rule can be hard to remember, but it is a basic standard of civilization.
Other attempts to extend the basic concepts of self-defense to larger bodies, including nations, have not gone well to date. Nationalist perspectives tend to warp any interpretation of factual events. Nations that have long histories of going to war with each other often use past wars as justification for why present aggressions are "self-defense." We want to allow nations to defend themselves against aggression, but of this has freuqently resulted in aggression being characterized as defense.
Two issues that complicate international matters are divided houses and third parties; they often go together. Imagine a family where two spouses are quarrelling and heading towards divorce. One spouse calls on outside friends to come over and throw out the other spouse. The other spouse grabs a gun and starts shooting. From the shooter's view the situation is self-defense, but the families of the people who are shot will feel there relatives got a legitimate invitation, and so will see it as murder.
Now imagine a much bigger house with a whole bunch of quarrelling families or ethnic groups or classes. That would be a nation. If one group feels it is losing a power struggle, or a civil war, it may call in outside help. Is the third party nation that helps a losing faction aiding in their self-defense, or are they an aggressor invading someone else's house? People usually judge this based on which faction they like. I believe any interference by an outside nation has to be counted as aggression, and therefore as a war crime. Otherwise there is always a pretext for aggressive war. A nation wishing to attack or absorb another nation can always find some discontented people in the victim nation to issue the invitation.
The Vietnam War is a good example of why nations should never interfere in the internal affairs of other nations, at least not by force of arms. To summarize a much more complicated situation in the context of this discussion of third parties and self-defense, before World War II Vietnam was a colony of France. There was a Vietnamese independence movement. After Marshal Petain set up a French Catholic fascist regime to cooperate with Hitler, Vietnam was turned over the the Japanese, mainly because they were going to take it anyway, but some French troops remained.
After World War II the English, Americans, French and Dutch mainly reneged on their rhetoric about national self-determination and ending colonialism. Vietnamese nationalists were not just upset when the French returned with their Parisian arrogance. They kicked their butts in war, even though the U.S. aided the French. But the imperialists had made some Vietnamese allies, who were mainly Catholics. After the French lost they declared they were really nationalists too. The Catholic friends of America and France set themselves up as the government of South Vietnam. The North Vietnamese regime, twice betrayed by the United States, leaned to the communist nations of China and the Soviet Union.
When the U.S. started fighting against Vietnam (with soldiers in the South and bombings of both the South and the North), it was by invitation to President John F. Kennedy. The Northern branch of the family was winning the family argument even in South Vietnam. The invitation came from Ngô Đình Diệm (Ngo Dinh Diem), the first self-appointed ruler of South Vietnam.
The U.S. soldiers were in the Vietnamese house, but were they aggressors? They had been invited, but by a minority-based government with no popular support beyond its Roman Catholic cadres (the majority of people in South Vietnam were Buddhist).
In retrospect, the U.S. should have refused the invitation. The U.S. lost the war and in the process ruined its own economy and lost a vast amount of international prestige.
Winning, of course, would not have made things right. A successful thief and murderer is still a thief and murderer.
What about when bad things are happening in a nation, like genocide? That certainly adds another variable to the argument. The analogy might be a woman calling the police to help deal with a murderous spouse. The problem is that this argument puts you on a slippery slope. Hitler argued, when taking over an assortment of territories before World War II got into full swing, that he was protecting the ethnic Germans living in those territories. The argument opens the door to all sorts of other arguments for invading other nations. Including invasions based on religion or political ideology.
So I'll stick with the general rule that no nation ever has the right to invade another nation. Nations have the right to defend their own borders; that is all. That is my analysis of the ethics of these general situations.