We won Afghanistan fairly easily (a few months), and held it fairly easily for 19 years. And not to trivialize 4000 dead, but if it had mattered, that would have been a pretty small sacrifice.
Where we failed miserably was at turning the result into a stable country, but Taiwan is already a country.
Besides that, stability is always relative, in the longer term no country is ever stable, in the shorter term in the case of countries like Afghanistan they are stable about as long as other nations don't cross their borders.
Vietnam, Afghanistan, Iraq, Iran and many others besides. All of these were at some point reasonably stable, and then someone somewhere decided to attempt to enlist them in one scheme or another and/or tried to wage a proxy war through them or actively tried to install regimes more friendly to foreign interests.
The Roman Empire in the long run also wasn't stable, but it fell to rot from within, as most countries eventually do. But in the case of Afghanistan the destructive force was applied from without.