*Who's* national security is undermined?
Everyone's. The core principle of NATO is that an attack on any NATO member will be treated as an attack on all NATO members. Thus, traditionally, Russia would be very reluctant to attack any NATO member because it would be guaranteed to bring about a strong counterattack, which at best would be costly to all parties and at worst could escalate into World War 3, which not even Putin wants.
However, if Russia has cause to believe that the USA will not honor its commitments to NATO, that could tempt Russia to try to "take back" one or more of the East European countries it lost after the cold war (similar to the way it "took back" part of the Ukraine in 2014).
By his loose talk, Trump has given Russia (and the world) cause to believe that he might decide not defend all NATO members; that the commitments of the USA might not be honored if Trump is elected.
So let's imagine that Trump is elected, and then Russia bets that Trump won't bother to defend, say, Lithuania, and so Russia sends in their troops to "reclaim" Lithuania.
Now what happens? Either Trump doesn't respond, in which case NATO is exposed a paper tiger, and Russia (and potentially others) now feel free to invade more countries when they want to; or Trump does respond, and now we're involved in a hot war with Russia that could easily turn nuclear.
Either outcome sucks. That's why politics at this level isn't a game, and shouldn't be treated as one. Trump's words have real consequences, even if he thinks he is only joking (or more likely, just isn't thinking at all).