On the contrary, it has to do with, literally, the security of the nation itself. Nothing more or less.
We wouldn't wait to establish martial law if necessary during invasion until the government were about to fall, after all. The Confederate invasion of Pennsylvania that was stopped at Gettysburg is about as "national security" as it got for the U.S., but that never directly threatened the U.S. government itself.
"Nothing more or less" sounds so precise, but "the security of the nation" is (like "national security") so vague as to be virtually meaningless without elaboration. "National security" is often abused to mean pretty much whatever the speaker wants it to mean. But it has always been very much about the continued existence and authority of the government.
"National security" as a concept and term didn't exist in the Civil War, but the main threat to "national security" at the time was the attempted secession of several states, which, had it succeeded, would have dramatically altered the power, authority, and nature of the US government.
But it would not have altered the existence of that government. It would, on the other hand, have threatened the republican form of government which the Constitution requires the government to provide for its citizens in Article IV.
Of course, I was speaking of actual invasion anyways, not mere secession.
It is completely absurd to suppose that even the most serious terror attacks in history (like the 9/11 attack) pose any threat to the continued existence and authority of the US government. But that is exactly what this line of reasoning assumes. That's what "national security threat" means.
We see this deliberate and erroneous conflation of "terrorism" and "national security" again and again in government statements and policies, and the media parrots it uncritically. Even if we believe that preventing terrorism is extremely important, terror plots and acts of terror do not generally rise to the level of "national security." Even if we accept the (extremely troubling) legal principle that the constitution may be weakened or ignored in the case of national security threats, that doesn't mean we should accept such weakening in the quest to prevent terrorism.