The American preference for making anti-communist allies, however unsavory, tied Washington to Pakistan’s increasingly Islamist dictatorship, while India’s non-aligned democracy drifted toward the secular Soviet embrace.