This actually ties in to the supply issue. China imports a lot of its food, and has been trying to diversify the foreign countries which it sources it from. Their big geopolitical concern is that the Strait of Malacca would be closed during a conflict, and most of the food/other raw materials that they import from Europe/Africa/South Asia that's shipped by sea flows through this narrow channel. Not only that, but the Andaman Islands, which are owned by India, can also shut off this shipping lane. Unlike us, who are self-sufficient when it comes to food and could be when it comes to many other raw materials, China NEEDS this trade or the country collapses, so they've prioritized establishing more stable and easily defensible trade routes. This plan is commonly referred to as Belt and Road, and is meant to establish both land routes to Russia and Europe through Central Asia and alternate land shipping routes to ports on the Indian Ocean. The most important of these ports are in Burma and Pakistan. China has been cozying up to both countries (remember the coup in Burma) in order to smoothly implement this project and ensure political compliance. The Pakistan/Afghanistan border cuts through the tribal territory of the Pashtun people; these are the ethnic 'base' of the Taliban. Part of what allowed them to hide Bin Laden for so long and evade being crushed was the fact that they are more loyal to their tribe than to either artificial country, making the border porous. Cozying up to the Taliban gives them another stick/carrot when negotiating with Pakistan, and gives them more leverage, as they can use that influence to make the Pashtun tribes be good boys and not cause trouble or to stir up shit.
The Chinese have zero interest in converting these people to communism. Communism for them is just a justification for a system of central control that allows China to function; they aren't evangelical about it. As a culture/people, the Chinese have never really had any particular evangelical/crusading fervor. One of the things that infuriated early European diplomats was that, when they told the Chinese Emperor about Europe and its Empires/Kingdoms, he simply said 'oh, I'm the Emperor of Europe too' and treated their own monarchs as vassals because China was the center of the world to him. This is where we get the word 'kowtow'; it's a deep, almost groveling bow that the emperor demanded of European diplomats, which they found deeply insulting. The West often has this 'convert/conquer/explore the world' mentality, China has a 'have the world pay homage to China' mentality. As long as the Pakis and the Taliban kowtow to Beijing, they don't care if they worship Allah or cows or the moon. The main reason they got hopping mad at the Uighur Muslims in China was because of separatist movements/terrorist activity within their borders. The Hui, another Muslim minority group that lives further south, enjoy much more freedoms and have been historically used by the central government to crush revolts by the Uighurs (the two groups HATE each other).
China is also incredibly sensitive about foreign influence, and that, more than ideological communism, is the impetus behind a lot of religious suppression. They don't like Salafist Muslim movements which are tied to Saudi funding and influence, and they don't like Catholicism for the same reason (explicitly tied to Rome and the west). They've actually severed the Chinese 'Catholic' Church's ties to Rome and have set up a parallel ecclesiastical structure, much as England did when the Anglican Church came into being. These churches have all the trappings of Catholicism, all the rituals, and all the titles, but just as the head of the CoE was the king/queen instead of the pope, the CCPA (Chinese Catholic Patriotic Association) reports to the UFWD. An interesting artifact of this was that the CCPA never got the memo after Vatican 2 and continued to practice the Tridentine Mass for years.
But anyway this supply line project is pissing off India, because it's basically two large arms that encircle India to the east and west (along with investments in Sri Lanka to the south). This, combined with China's aggressive territorial claims, basically means that China has India by the balls and can squeeze whenever they feel like it. That, to them, is worth way more than having every Baluchi and Pashtun dirt farmer reading Mao's Little Red Cookbook.