Or the justifications for wars can change, but they are not necessarily the real motives.
Back in the 19th century, the British were very direct about their wars. The purpose of the wars was to defend and expand a global empire for the profit of people in London. Britain fought two opium wars with China to make that the profitable British drug trade was not interrupted.
Opium trade was an important factor in the Vietnam War as well, but that was never part of the official narrative. Instead, the war was about stopping Communism and spreading “democracy and freedom”.
Likewise, opium was a big factor in the war in Afghanistan. The year before the US invasion, the Taliban virtually stopped opium production. During the US occupation, opium product shot back up to high levels. Since the Taliban have retaken control, opium production has gone back to pre-invasion levels.
As starting point to understand why the US was in Afghanistan for 20 years starts with one simple question: Who profited from the opium that left Afghanistan during the US occupation?