It's not like the United States hasn't allied with Pakistan. The Pakistan factor does count but it isn't decisive.
So, why does such hostility emanate from India?
1. Indians elites are westernized - Major icons of Indian independence were English educated. Nehru studies in Harrow and Cambridge. Indian deep state, which is the Indian bureacracy too have strong personal interests in the west. Western education and exposure then results in adoption of western ideas.
2. Surge of the Right - Indians see the red flag with yellow stars and their brain explode. There is hate and only hate for the communists. Days of Indian socialism are over, the country is wholly consumed by the dominant ideology of the day. (Heck, even the Indian socialists too talk like capitalists and have reserved hatred for cpuntries like China)
3. Aggressive Nationalist agenda - The ruling party has pushed forward with a Nationalist campaign. The consequences of this are quite visible on the digital space and I am sure everyone here has encountered this.
These three things guide Indian discourse with other nations and people around the world. The UNSC seat, support for Israel, the 'Chinese numbers are fake', etc., all BS is based on any one of these factors.
Now is there any chance that the Indian state realigns with foreign policy? Yes, the failure to draw investments from China has hurt Indian businesses, and they are quietly lobbying the state to change it's stance on Chinese investments. The economic factor will have tremendous influence on India-China relationship. No matter who, countries around the world just can't thrive by just ignoring China and Chinese money.