What is meant by not taking the Jews and Christians as awliya? What were the reasons for these verses being revealed?
You are referring to the verse in surat al-ma'idah: 5:1, it is best translated as follows:
"O you who believe, do not take Jews and Christians as your closest allies, for they are only the close allies of each other. Whoever among you turns to them (for alliances, in place of believers,) is one of them, for God doesn't guide corrupt people." (Qur'an: 5:51).
The verse in no way implies establishing normal friendly and amicable relations with either Christians or Jews or anyone else (who is not a Muslim). It specifically refers to siding with them against Muslims, or joining with them on causes that are clearly detrimental to the interests of Islam and Muslims.
The above interpretation is confirmed by a close study of the context of the revelation of the verse: It was revealed, as stated by the great mufassirin (exegists) such as Imam Ibn Jarir and others, in the context of the alliance of Jews with the pagans in waging war against Muslims. When the Jews of Madinah did this, some Muslims from Ansaar, who had been formerly allies of Jews, declared their innocence of them, while others (apparently the hypocrites) still persisted in their alliance--in clear violation of the interests of Islam and Muslims.
Therefore, the above verse is specifically forbidding Muslims against forming alliances with others against the interests of their own community as well as siding with them on causes that are immoral or considered as unjust.
Seen in this light, it does not in any way forbid Muslims from having normal friendly relations with members of these communities or cooperating with them on causes of mutual benefit. Not only these are permissible but also clearly recommended in Islam: Allah tells us,
"...And never let your hatred of people who would bar you from the Inviolable House of Worship lead you into the sin of aggression: but rather help one another in furthering virtue and God-consciousness, and do not help one another in furthering evil and enmity; and remain conscious of God: for, behold, God is severe in retribution!" (Qur'an: 5:2)
The Prophet (peace be upon him) said, "(In pre-Islamic times) I attended a pact of virtue in the house of Abd Allah b. Jud'an: If I were called in Islam by anyone to join a similar pact, I would never hasten to join it!"
Furthermore, it is an incontrovertible fact that the Prophet (peace be upon him) turned his foes into his bosom friends by his mercy and friendly relations with them.
In conclusion: The word awliya in the verse referred to above means making them allies against Islam and Muslims.