It's all false propaganda, however, as an examination of each foreign war in which U.S. soldiers have fought and died will easily show.
The Spanish-American War. That war had nothing to do with protecting the freedom of the American people. It was all about converting the United States into an empire, one with colonies, just like the Spanish Empire and British Empire. Thus, U.S soldiers who fought and died in the Philippines were simply trying to suppress the Philippine independence movement, which never threatened the freedom of the American people.
World War I. Germany never attacked the United States. The U.S. government intervened in a European war with the aim of "making the world safe for democracy" and in the hope that U.S. intervention would make this the world's final war, both of which were extremely foolhardy goals. In any event, American freedom was never at stake.
World War II. Neither Germany nor Japan wanted war with the United States. President Roosevelt maneuvered and cornered Japan into attacking the United States in order to give him a "back door" to entering the European conflict. The sole aim of the Japanese was to knock out the U.S. fleet at Hawaii, in the hope of preventing U.S. interference with its seizure of oil fields in the Dutch East Indies to fuel its war machine in Korea. Japan was never going to try to invade and conquer the United States.