It varies by region.
The US got involved in Korea because it was the only nation capable of backfilling the power vaccum caused by the defeat of Japan.
The US got involved in Vietnam because it was the only nation capable of backfilling the power vaccum caused by a collapsing French Empire.
The US got involved in the Middle East to backfill a power vaccum caused by a collapsing British Empire.
When the balance of power changed as a result of World War II, the only nations left standing to fill power vaccums were the Soviet Union, the United Sates, and the emerging Chinese People's Republic.
When empires fall, their neighbors fight over the pieces.
The best way for America to avoid involvement in further forever wars is to have strong allies to blunt the aggressor tendencies of other forces in the region.
It makes strategic sense for the US to remain engaged in East Asia to check the imperial ambitions of the People's Republic of China and in Europe to check the imperial ambitions of Putin.
The Middle East is a different story. The Middle East is a region of powers competing amongst themselves to establish dominance or hegemony over the region - Iran, Turkey, Saudi Arabia / United Arab Emirates. Also China and India will be drawn in as they develop dependencies upon Persian Gulf oil.
The biggest risk in the Middle East is nuclear proliferation. The 2003 American invasion of Iraq and the 2022 Russian invasion of Ukraine demonstrated or confirmed that nations without nukes are susceptible to foreign invasion. Iran is seeking nukes to deter the US (and maybe Russia). Saudi Arabia will seek nukes to deter Iran. Israel already has nukes. Turkey may seek nukes if it feels threatened by Russia, Iran, and possibly Saudia Arabia. Europe, and possibly NATO, may be drawn in to protect Freedom of Navaigation through the Suez Canal and the Red Sea.
American boots on the ground is a big mistake in the region. Also, as the British abandon Diego Garcia to the People's Republic of China, it would be advantageous of the United States Navy to acquire the Islands of Socotra as a forward operating base. That would allow US and allied navies to protect Freedom of Navigation in the region without having to put boots on the ground on the Arabian Peninsula.