Initially, we invaded to depose Saddam and destroy his WMD programs. So when at first the programs weren't there, we had to keep some troops in the country to look for them. What's more, some kind of new government had to be created. But then, contrary to what the Bush administration had expected, an insurgency started against our presence. The insurgents were killing our troops. Then beating the insurgents became the goal. Our troops had to stay in Iraq and risk their lives in order to kill the people who were trying to kill them to force them out of Iraq -- we couldn't leave until all the people who wanted us to leave were dead.This captures the essential thirteen-year-old mindset of the Republican approach to this war: "I'll go as soon as you stop asking me to leave. So there!"
Defeat would be being perceived to do something that our enemies want us to do. In other words, we have no desire of our own, only the resentful desire to frustrate the desires of our enemies. If they want (or seem to want) x, then we want not-x. This is paradigmatic stupidity.