Every jurisdiction is a little different, but...
You can use as much force as is necessary in self defence. Basically, if a guy is standing on the other side of the room with a knife and talking like he'll kill you, you can't shoot him. But if he
charges you with the knife, then he could be conceivably be getting in range to do bodily harm and he seems to have hostile intent, so
now you can shoot him. You can intervene to save a bystander under the same logic.
So I think you are safe enough to kill in the school shooting case, as long as you're reasonably sure everyone you kill is a danger to the safety of yourself or other students. You couldn't hurt someone who surrendered or gave you no reason to expect trouble from.
In the bank case, now that you've added say "you hit him in the head ONLY IF HE KEEPS ATTACKING YOU" you should be ok. If a robber is attacking you you're allowed to hit back, and if you kill him by accident you'll probably get off alright. Especially if you have all these witnesses seeing you being attacked and you did nothing to provoke it. But you can't attack an unarmed robber or beat to death an unconscious one.
If the robber hasn't harmed anyone and seems to be willing to leave if given the money, I believe you have to let him go. You can't attack him because you "were scared he might turn violent" - he has to give you some additional reason to expect violence.
You could always try a citizen's arrest first, btw. Unfortunately, I doubt that'll work too well.
How ya doing, buddy?