"Shooting down the plane" is unlikely to fall under Notwehr in germany
In Germany, the fact pattern as described is impossible to achieve and still grant Notwehr. Notwehr is not the same as self defense under common law, but that is the best translation. In contrast to the wide latitude given in for example US law, it is incredibly tightly defined in Germany.
In Notwehr, one may under no condition risk the harm or death of any person besides the pilot, even if they find a way to somehow kill the pilot in self-defense, and you only may use proportional force to the threat. That excessive risk by the wreck of the airplane or killing the passengers can all be treated as separate charges of reckless endangerment or murder (as death was taken willingly into account). In Germany, self-defense does not allow Bob to harm or kill those others, and threatening them with his illegal backyard stinger, in turn, allows anybody to defend the passengers by shooting Bob first.
This hinges on a particularity of the law: You only are allowed to use the least forceful means that are effective to stop the crime, and shooting the pilot or plane is most likely not an effective means to stop the plane from crashing into the building (as proffered by OP) in the first place. Or to stop any other crime that could be conducted with a plane. Also, you are only allowed to use lethal force after having given a warning of some sort - which is clearly lacking in this case. As a result, it might be an extreme case of Notwehrexcess (excessive self-defense) to shoot down the plane, especially without warning. Shooting down a plane simply lacks Gebotenheit under German law, which is a crucial part of an analysis of Notwehr.
Note that while Gebotenheit can be translated with necessity, that is not a good translation at all, even a worse one than to translate Notwehr as self-defense: Gebotenheit does not just cover the need for a specific action, that it is proportional to the danger and that it is is able to have success. Shooting a person armed with a rubber chicken is not geboten as it is neither required nor proportional, and shooting a plane down is unlikely to be geboten as it is unlikely to have the intended success while endangering others.
To stay with the example of OP: No means of shooting a plane "down" will stop a plane from crashing into a building once it becomes apparent that the pilot can no longer avoid crashing into the building, and likely doing so is a case of Extensiver Notwehrexzess (extensive excessive self-defense).
Shooting the plane "down" before it is clear that the plane will crash into the building is an unlawful killing and clearly Extensiver Notwehrexcess, possibly even Mord of the pilot. This is because a pilot might avert a plane to not crash into the occupied building until about two seconds before the catastrophe - and so there was no situation that required Notwehr at all, and you had no right to apply it in the first place.
Shooting the plane after that point, where the crash has become inevitable and Notwehr would start, doing so does not stop the debris to follow Newton's Laws and crash into the building, and thus shooting the plane "down" is clearly not an effective means to stop the death of people in the building. The act isn't covered by Gebotenheit. However, that might only be Intensiver Notwehrexcess, and the shooting of the plane thus might not be punished.
However, that would not excuse any other violations of law that needed to happen to shoot the plane in this way, such as illegal possession of a firearm that is able to destroy the fuselage (most of which are illegal to possess under the Kriegswaffenkontrollgesetz (War Weapons Control Act) in the first place)
But even the military is not allowed to shoot down a plane:
The first organization that for a short time was deemed able to decide to shoot down a plane in Germany was the Einsatzführungskommando der Bundeswehr according to the 2005 of § 14 (3) LuftSiG. But that was declared void in 2006, which led to a new version in 2009, which was then deemed valid in 2013 under BVerfGE v. 20.3.2013 I 1118 - 2 BvF 1/05. This current version of §14 (1) LuftSiG does not permit to actually shooting down a plane at all:
(1) Zur Verhinderung des Eintritts eines besonders schweren Unglücksfalles dürfen die Streitkräfte im Luftraum Luftfahrzeuge abdrängen, zur Landung zwingen, den Einsatz von Waffengewalt androhen oder Warnschüsse abgeben.
In English: To prevent an aircraft disaster, the armed forces may force an aircraft out of German territorial airspace, force it to land, threaten the use weapons or give warning shots.
Note that this law does only handle civilian aircraft, not military enemy incursions in case of war - those are handled as enemy combatants and are fair game to shoot down for the armed forces.