The CIA had cooked up a bonkers covert mission to send a submarine with an airlock right into the soviets’ top submarine harbor. There, divers were to place a tap an underwater data cable that fed the nearby submarine base—a crown jewel of Soviet sub deployment intel.
The CIA knew the cable passed through the harbor somewhere. But where?
To search the entire harbor for a tiny cable would have taken too long. The mission planners were stuck on this problem until one day one of the CIA planners is out on his personal boat. He sees a sign that says “WARNING: Undersea Cable” and has a moment of clarity.
They brought a translator, popped up the periscope in the Soviet harbor, and spotted an equivalent sign which they used to carry out the mission successfully.
For extra credit they had to go back to exfiltrate the data if my memory serves.
Clever!
Anyway, we definitely can protect installations from stand-off weapons: CIWS systems like the Phalanx can shoot them down these days, and they're relatively cheap. It's not perfect protection - eventually one will get through - but it does raise the cost of a successful attack substantially.
Ideally, in war, you destroy their military, or at least damage it enough for the other party to concede and discuss peace terms, and leave the rest alone.
WW2 was, I believe, the last war where they went for complete destruction of infrastructure, industry, and civilians. The Allies firebombed Dresden and nuked Hiroshima and Nagasaki. It is estimated that 50-55 million civilians died in WW2, of which part due to disease and famine. No conflict since has had that high a civilian casualty rate.
Military is a deterent because of the threat of retalitation, not because they literally prevent other countries from doing things in the moment.