My observation is that invasions happen more often in relatively defenseless countries (compared to their aggressor) than well-guarded countries. In the entire course of the cold war and beyond, the United States never invaded Russia or vice versa. Despite the United States's adversarial relationship with China in recent decades, the U.S. government has been reluctant to enter into any military conflict with them. Invasion of nuclear powers is scarce. The U.S. invaded Iraq under the false pretense that they were developing nuclear weapons, but the U.S. government has never invaded a country that they knew had nuclear weapons. North Korea has had a nuclear weapons program since the 1980's and has been out of compliance with the UN Security Council since 1993, but the U.S. never bothered to invade and disarm them. Saudi Arabia is the most militarily strong country in the Middle East, and it is also an Arab country that the United States has shown little eagerness to invade, despite being the home country of most of the 9/11 hijackers; but the U.S. has conducted various campaigns in militarily weaker Arab countries like Iraq, Syria, and Afghanistan. In recent decades, Russia has invaded Ukraine, Georgia, and Chechnya; having little to do with whether they pose a military threat. Iraq invaded Kuwait despite Kuwait not being a match militarily.
It is rather rare in recent decades that invaded countries have been militarily mighty. There have been dozens of often not-well-known invasions perpetrated against militarily weak nations. Some notable exceptions have been the various invasions of India, the conflicts involving Israel, and the invasions involving Iraq. It can be conjectured that all of these classify as too much personal grudge to care about the defending nation's strength, or overwhelming military superiority of the invading country.
I believe a better defensive system would be to maintain a small to medium-sized military, operate a strong economy that is not weakened by excessive military spending, and maintain good diplomatic and military alliances. Switzerland's model of military neutrality and good diplomatic relations has helped it become the most economically and socially well-off country in the world (note: Switzerland DOES have a small military with a budget of about $4.8 billion). But the virtue in maintaining a small military, rather than no military, is it gives you more military capital with which to trade military alliances with other countries.
It can also be observed that in recent decades, there have rarely been invasions perpetrated against wealthy, industrialized, liberal democracies in the West. Specifically, in the 84 most recent invasions, the only a few have been directed against western democracies, only their distantly-held territories, not mainland invasions (Spanish and French territories in Morocco, British-controlled Falkland Islands, Dutch-controlled Papau New Guinea, Portuguese territories in India). This likely has to do with having neighbors who are also modernized liberal democracies. It can be reasoned that if a country provides humanitarian aid to help its neighbors to stabilize, establish a constitutional democracy, improve their education, and improve their economic health; then they can help stabilize their local geopolitical situation. Stable neighbors create an ally and eliminate a potential enemy at the same time.