Brad makes some great points, but I want to add something on Karzai. I think he is a very weak leader - not necessarily because he doesn't have strong backing aside of the international coalition, personally he is just a very weak and vain person.
When he became the president, the first thing he should have done was to strengthen the state apparatus, especially the rule of law. This would have had a huge impact, as the Taliban was still demoralized and unable to mount a strong organized attack to the government. By strengthening the rule of law, he could have strongly differentiated his regime from the Taliban's, showing that the Kabul government was much more responsible and thus legitimate.
Once the Taliban grew back in strength, thanks to the Pashtun people's dislike of the government, reinforced by what they saw as a massive corruption in Kabul, the Afghan government had very little legitimacy left. Why would Afghanis choose a corrupt government that could do nothing to help their lives over a murderous bunch of thugs who promised to provide protection, despite the ideological baggage? Not surprisingly, some people have picked the latter.
On Pakistan: I think there's a famous analogy which sadly I forgot at this moment. It goes roughly like this: someone who is so afraid of an enemy or a killer coming from outside is not prepared to the possibility that his offspring or family member might murder him due to greed or mental illness. Or a hypochondriac who keeps drinking a certain tonic to stay healthy, when in fact the tonic is consists of Mercury and arsenic, which are, of course, fatal to the hypochondriac.
The entire security apparatus of the Pakistan is oriented toward possible apocalyptic confrontations against the much stronger India. Having been involved in several wars already that resulted in Pakistani losses, a lion's share of Pakistan's budget is then dumped on the military (a whopping 60% of annual budget was spent on arms and debt maintenance! compared to India's 13% in 2010). Pakistan is afraid of losing the arms race against India, which is actually far more concerned at this point with the rising power of China.
To keep up the struggle against India, the Pakistani intelligence and military bodies decided to recruit Islamists, religious zealots, etc. At least they can trust their co-religionists who would abhor the idea of living under the Hindus, or so they believed. Plus, zealots are cheap: they are willing to suffer, live in a harsh condition for the sake of God, and very loyal, making them cost effective "food for powder" to fight India. Not surprisingly, the Pakistanis are arming the Talibans, Mujaheddins, and other groups to run a proxy war against India.
The Pakistanis, however, are not prepared for the possibility that the zealots, such as the Taliban, may actually see the Pakistani regime as un-Islamic because the state is not seen as Islamic enough. That is the root cause of current disorder in Pakistan.
On one hand, many people within the intelligence and military apparatus do realize that the Taliban and other religious zealots are not that good after all. On the other hand, they are deathly afraid that cracking down on these groups could reduce their ability to confront India, giving the Delhi potential advantages to strike.
Politically, these radical groups are popular. Thanks to the fact that 60% of Pakistan's budget is spent on military and debt maintenance, there is very little money left for social services, such as education and health service. Exacerbated by massive corruption in every level of Pakistani bureaucracy, there is simply nothing left for the people and the Islamists fill in the vacuum by building religious school and providing medical services. Not all religious schools are bad, but many, sadly, are simply horrid, as they operate simply as politico-religious indoctrination centers. Not surprisingly, when a moderate governor and a cabinet minister were recently killed, the reaction within Pakistan was divided: one huge part actually celebrated the murderers, claiming that the killers were defending the religion.
So can Pakistan be a useful partner in taking care of the Taliban and al-Qaeda? Yes and no. No, because as I mentioned, the Taliban are useful to fight India. I think the Pakistanis calculated that the U.S. may not have the political will to stay in Afghanistan over the long-run, while Pakistan will still have to fight India in 15, or 50, or 100 years. It is in Pakistan's best interest to keep Taliban alive, to prepare them to fight India when they are needed in the future. Plus, there is simply no political will to tackle the "defenders of Islamic values" crowd, especially when everyone knows that the infidel United States is pushing Pakistan to do that, even though the Islamists and Taliban are like cancer that slowly kills Pakistan from the inside.
To make it worse, Pakistani intelligence and army may have a vested interest to keep Taliban alive. First, they can keep getting assistance from the United States, which they will use not to fight Taliban, but to further prepare for the inevitable invasion from India. Second, fighting India is profitable: the fact that Pakistan will have to keep buying shiny bright gadgets such as fighter jets means that a major share of the annual budget will keep going to the army and intelligence. Should Pakistan decide to bury the hatchet and make peace with India, then the military and the intelligence may face massive budget cuts, something that they do not want. Thus, they cannot orient the mission of their armed force to fight the Taliban.
The "yes" answer is the sad fact that Pakistan remains the gateway to Afghanistan. The United States needs Pakistan to keep its supply lines open. But Pakistan can boost its usefulness only when it starts taking care of the Islamist cancer that slowly devours the country.
But overall, I think Pakistan is more of a problem than a solution to the Afghanistan mess.