I don't buy that we are planning to leave American troops in Afghanistan for ten more years because we are afraid of terrorist attacks originating there. Al-Qaeda and Osama bin Laden set up operations there because it was a weak state out of the public spotlight. Today there are many other countries in a similar situation -- Somalia, Mali, Libya, and others. The Taliban pretty much hate Americans, but there are lots of others around the world who feel the same.
On the other hand, Afghanistan would be a useful base of operations for an invasion of Iran next door. The decision to keep troops in Iran probably has more to do with American and Jewish hatred of Iran than it does with the security of Afghanistan. It's not enough to appease Netanyahu for a US-Iranian nuclear agreement, but it's better than nothing.