All countries which play the geopolitical game have "enemies". Pakistan and China are geopolitical allies, the Belt and Road initiative runs through Pakistan while Pakistan provides a port to China. The two states have very little in common ideologically, but as is the norm in geopolitics, common interests usually trump ideology.