Spoony
The People's President
Not out of the goodness of their hearts, but it's better to maintain good relationship, invest, and reap the fruits of their investment later on compared to having an unstable region.
Those tanks and bombs aren't cheap, and they aren't doing a very good job of winning hearts. Maybe it's time for cheap smartphone and railways tracks and jobs. Even the most battle hardened fighter can't resist a good korean drama they say.
Having Afghanistan as an ally worth a lot in the grand scheme of things. Having China as an ally also helps economically, much more than relying on the western pennies. These days only China have the money and manpower to jump in and built your nation, regardless of what they ask in return, at least it's better than guns on your head. Taliban if they're smart knows that the war is already won, it's time to look forward if they want to maintain power.
China have got some clout in the region, as you've said they'll invest in Afghanistan, and with that a clear run with its Belt and Road initiative, they've given Iran billions for connection to Chahbar and they've already developed a port in Pakistan for a direction connection to the Persian Gulf. Only a few months the back they made India surrender parts of its country. Seemingly very shrewd.