President Xi Jinping is spending more than $50 billion in an economic corridor in Pakistan, Afghanistan’s neighbor. The highways and gas pipelines, designed to provide China an alternative land route to the high seas, also give it an interest in stabilizing the volatile region.