Strategic position? Capable military leaders? Taliban incompetence? What’s the answer?
Ahmed Rashid's works on the Taliban are a good source for this topic. The Northern Alliance managed to hold out in a relatively small area due to a combination of multiple reasons.
Some of their military commanders were very capable, such as Ahmad Shah Massoud.
The factions that made up the Northern Alliance had previously lost huge areas to the Taliban. By 2001, the terrain they ended up in was geographically good for defensive tactics. The brutality of the Taliban to the Hazara, their breaking of agreements with the Uzbek faction of Dostum, and all factions losing territory and resources, created the situation whereby the factions of the Northern Alliance had no other choice than to stick together.
The Northern Alliance received just enough support from neighbouring states like Uzbekistan and Tajikistan to hold out. Alleged opium smuggling was also a vital source of income.
Also, maybe less straightforward and more controversial, the Taliban had no immediate gains in achieving a final victory against the Northern Alliance.
The Taliban had conquered most of the territory and population centers. The war in the north had become a stalemate. Achieving the final victory with a major offensive would have cost a lot of lives and resources. There is also an advantage to keeping the civil war going in this way, as it is easier to maintain a sort of wartime economy and authoritarian leadership when the regime remained 'under siege'.
It also diverted the attention from their foreign allies such as the Islamic Movement of Uzbekistan. It would serve the Taliban's interest to have them keep fighting the Northern Alliance in an insignificant area, and divert their attention from incursions into Uzbekistan or from efforts to establish a Central Asian caliphate. Becoming more of a threat to other Central Asian states, and Russia, or potentially even China, was not in the immediate interest of the Taliban. Just like it was not in the Taliban's interest to be attacked by the United States after 9/11.