The aim in any successful counterinsurgency is to support and strengthen a sovereign and friendly government. The inherent paradox is that use of US military power, or even US diplomatic leverage, to achieve that aim undercuts the perceived legitimacy and sovereignty of the government it seeks to support. Enemies exploit this paradox to their benefit, labeling US troops as occupiers and governments allied with us as puppets, undeserving of support from their own people.
From Vietnam to Pakistan to Iraq and now Afghanistan, this is a lesson the United States continues to get wrong - making short-term decisions with unintended long-term consequences.
In 1963, the United States supported a coup against the corrupt but allied president of South Vietnam, without asking what might come next.
For 30 years the United States has whipsawed Pakistan from close ally to sanctioned adversary and now, to something in between: a partner, but under unilaterally imposed conditions that may sound nice in Washington, but weaken the very government we seek to help.
In Iraq, from 2004-2008, the government failed to take root with the Iraqi people, despite electoral legitimacy or broad-based coalitions. The US military, under a broad mandate from the United Nations, was authorized to take any action it deemed necessary to contribute to the stability of Iraq, often against the wishes of Iraq's elected leadership. The result was constant tension with the government we sought to support, and a continued nationalist-based justification by extremist groups to fight US and Iraqi forces.