The security in courthouses and government buildings is primarily there to protect the judges and public servants from the public, who enter and exit through separate ways from each other.
And in addition to separate exits, there are secure and guarded carparks, panic rooms, and various other kinds of strong internal security - right down to the presence of bailiffs in every courtroom (and probably scores in a courthouse in total, who unlike the judges are expected to be sacrificial during an attack), and a judge who sits at a high bench which is difficult to scale quickly from the public side and probably bulletproof.
And judges tend to ride in heavy cars, and may have police minders and escorts if they are particularly at risk, and they rarely congregate in large numbers in the same place. If there would be queues for judges to enter a courthouse from the street, then they would stagger their start times to eliminate the queue, or rework the entire building to increase the number of entrances (and sufficiently man each of them).
So too in airports, the security is primarily designed to protect buildings and installations into which a large aircraft may be flown, and to a lesser extent the aircraft itself, not to protect the passengers, and scarcely even to protect the staff (who are probably never specific targets anyway).
The public in these places, meanwhile, are usually relatively easy to attack - at least in the same sorts of numbers as are claimed in a typical school shooting.
At courthouses and especially airports, there are often dozens if not hundreds of members of the public stood in queues or waiting halls, who could be sprayed by guns or blown away by explosives, particularly if the assailant had no intention of escape.
If you look at from this perspective, it's quite obvious that the public cannot be protected in schools because they aren't protected even in the examples you adduce!
Nor are the public protected in a wide variety of other everyday settings - pubs, clubs, theme parks, and so on.
The real solution is probably a stronger sense of civility and shared community, stronger control on weaponry, and stronger means of avoiding or resolving extreme grievances that underlie many of these attacks.