In a post-nuclear world, this is incredibly complex so it usually ends up playing out in different theaters (Korea, Vietnam, Iran, Syria, etc.) rather than the shores of the U.S. as you pointed out, but the total reserve and reach of that force is still just as important.
The argument can get slippery though when trying to justify allocating resources, because with deterrence it's hard to know exactly how much you need, especially when gaining that knowledge usually comes through defeat of some sort.
Much of Mexico's territory is de facto controlled by enemies of both Mexico and the USA, and Russia has, or at least is eyeing having, an outpost in the Caribbean right now.
The US used its army directly in the New World at least as recently as 1982, in the invasion of Grenada.
Or even more recently in '89 down in Panama.
Or in Haiti in '94 -- though that one wasn't necessarily an invasion but the troops were in the air if diplomacy failed.
It's hardly similar circumstances. An attack on the US mainland today would mean global nuclear war. It's highly improbable to ever happen.
So you're saying the US should have nuked Afghanistan? I think you have an oversimple view of international relations and military affairs.
Or enact similar immigration restrictions, like Trump did about a year ago.