Is there a sort of psychology in which nations protect their identities and futures by identifying threats and keeping their populations concerned about them?
There is in fact a practice -- and this answer will go beyond the narrow confines of U.S. foreign policy and take a more global approach -- of autocratic countries using the notion of foreign threats to divert their populations from domestic problems. A classic example of this was the Argentinian military junta's 1982 decision to invade the British-occupied Falkland Islands in the South Atlantic. While there is a legitimate territorial dispute between Britain and Argentina over the proper ownership of the islands, the British had occupied the Falklands since 1892, and there was no casus belli involved by which Argentina could logically militarily seize the disputed territories ninety years later. The military regime of General/President Leopoldo Galtieri calculated that appealing to Argentinian and Spanish pride by seizing the Falklands would divert the population's attention from the misrule and human rights abuses associated with the regime. The gamble backfired, and the country was humiliated by the British military victory, which resulted in the military regime's fall from power.
The Chinese Government frequently comes close to precipitating a war with Japan, which many Chinese continue to hate because of the incredible brutality of the Japanese occupation of Manchuria during the 1930s. Whenever the Chinese Government wants to divert its population's attention away from human rights abuses, it provokes a response from Japan, which causes massive Chinese demonstrations against Japan.
The most compelling example is the North Korean dictatorship under the regime founded by Kim il Jung and followed by Kim's son, Kim Jong il, and, today, grandson, Kim Jong Un. North Korea's human rights situation is among the worst in the world. Mass starvation and repression directly resulting from government policies require the North Korean regime to occasionally provoke crises with its neighbor to the south, the United States, and/or Japan (which had also occupied the Korean Peninsula during the first half of the 20th Century). Such provocations, usually involving tests of ballistic missiles, detonations of nuclear weapons, or direct military attacks on South Korea, help the North Korean government to rally popular support behind it and to justify its repressive measures. By playing up the notion of a foreign threat, especially from the United States, the regime is able to blame the country's problems on foreigners and minimize the threat of popular discontent with the Kim family's rule.
These are only a few concrete examples of governments exploiting their populations' fears of the outside world for domestic political effect.
This sort of psychology is a major part of what the country of Oceania in George Orwell’s 1984 does to maintain its identity and future. It is less clear if countries in real life do this. People who would say that countries do this typically have a negative attitude about the countries (or the leaders) that they are accusing.
Whether countries do this is really in the mind of the person observing the country. For example, let us look at the “War on Terror.” On the one hand, if you are inclined to support what the US is doing, you would say that the war on terror is a legitimate response to a real threat from Al-Qaeda. They would point to the attacks that that group has carried out and say that the US really has an objective need to be concerned about the group.
However, a person who is more cynical about the United States or about a particular president could argue that the US really is just engaging in the War on Terror as a way to keep Americans in line. The government points out Al-Qaeda as a threat to us so that we can feel more solidarity with one another. It keeps us in a state of fear of Al-Qaeda so that we will not complain about infringements on our liberties.
The point, then, is that it is impossible to say objectively that countries engage in this sort of an action. We can argue that they do, but there is not really any objective way to prove that it is so.