Becoming someone’s ally is not a simple form of relationship or of social dealings; it rather implies loyalty, support, and affection that are given precedence over the religion of Allah. That’s why the warning is clear, so as to prevent the believer from straying away from the path of truth.
The Quran teaches us that true allegiance is due to Allah and to the believers, and that Allah knows what is concealed in hearts and what tongues proclaim; nothing can be hidden from Him, neither the sincerity of allegiance nor its falseness.