You wrote: "Now, let’s take a look at some very interesting verses. It talks about those idolators, who while in their state of idolatry, nevertheless perform Salat and give Zakat:”
Dear brother, the confusion you have is not taking the context into consideration. My two cents below along with a bit of history necessary to know what precipitated these verses.
Chapter 9 records a historic struggle coming to head towards the end of prophet’s ministry. It starts with discussing some sort of pledge/covenant/treaty with pagan Mushrikeen. The treaty in question is well known as Treaty of Hudaibiyah in Islamic history. One of the clauses of the Treaty of Hudaibiyah was that Meccans would not fight against any ally of the Muslims, nor should the Muslims fight against any ally of the Pagans. The treaty was broken by some pagan tribes when they attacked a tribe allied with Muslims. Prophet sent an emissary to Meccans to persuade them to accept any of the following terms: Reparations should be paid for the massacred people of tribe, or the Quraish as a chief tribe should break their alliance with their ally tribe who participated in attack, or the Treaty of Hudaibiyah should be abrogated.
They accepted the last alternative, i.e. the Treaty of Hudaibiyah should be abrogated. The Prophet marched with his men and camped a short distance from Mecca. Eventually the city was captured in 8 AH without a fight and the prophet forgave even the chiefs of the warring tribes who were at the forefront to kill him. However the fight was far from over and it continued over next about two years. Some of those who broke the treaty they fled to another town named Taif and regrouped to fight another day. Chapter 9 (The Repentance) details some of the conditions prevailing at the time. Not all verses are responding to one single episode, rather to many episodes during that time period. For the purpose of our discussion, we divide Meccan mushrikeen in two groups:
Group A: Who adhered to the treaty of Hudaibiyah
Group B: Who did not adhere to the treaty of Hudaibiyah
Verses 9:1-2 are referring to God and Prophet’s disassociation from the above treaty with Mushrikeen who did not keep the covenant, group B. Four months are given as a cooling/repentance period.
[9:3]: And [it is] an announcement from Allah and His Messenger to the people on the day of the greater pilgrimage that Allah is disassociated from the disbelievers, and [so is] His Messenger. So if you repent, that is best for you; but if you turn away - then know that you will not cause failure to Allah. And give tidings to those who disbelieve of a painful punishment.
1. Please note in 9:3, the treaty-broken mushrikeen, Group B, are being asked to repent, to adhere to the terms and conditions of the covenant within these four months.
2. 9:4 has an exception clause, God asking Muslims to fulfill the covenant with those who did not break it, group A.
[9:5]: And when the sacred months have passed, then fight/kill the polytheists wherever you find them and capture them and besiege them and sit in wait for them at every place of ambush. But if they should repent, establish prayer, and give zakah, let them [go] on their way. Indeed, Allah is Forgiving and Merciful.
[9:6]: And if any one of the polytheists seeks your protection, then grant him protection until he may hear the words of Allah. Then deliver him to his place of safety. That is because they are a people who do not know.
3. Please note, the above group B is now comprising of two kinds of people, B1 who would seek Muslims protection and don’t want to fight, and B2 who would continue to violate the treaty as well as fight. The group B1 is to be protected even if they are still Mushriks and continue to be Mushrik.
4. The group B2, who are treaty brokers, have not gone back to the original treaty are now given a choice in 9:5, either repent, become Muslims, and join the Muslim community by establishing prayers and giving Zakah OR be ready to fight, be killed, arrested, etc., after 4 months if not gone back to the treaty.
[9:7] asking Muslims to continue adhering to the treaty as long as pagans do so. [9:8-10] is talking about the characteristics of these treaty brokers, namely, they defied the peace treaty and disregarded even blood ties, they pleased the Muslims with their mouths, but there was hatred in their hearts. After this:
[9:11]: But if they repent, establish prayer, and give zakah, then they are your brothers in religion; and We detail the verses for a people who know.
5. Please note, now in 9:11, the treaty brokers B2 are asked to repent, to become Muslims, establish prayers,….etc. This verse is incentivizing them to become Muslims and join the fraternity. This was/is always Quran’s call, to call people to be Muslims.
[9:12]: And if they break their oaths after their treaty and defame your religion, then fight the leaders of disbelief, for indeed, there are no oaths [sacred] to them; [fight them that] they might cease.
6. This again is referring to those in B2 group who continue break their oaths of treaty, to continue to defame the Deen, then Muslims are to fight the leaders of this band until they seize doing so.
In summary, those who adhered to the treaty (group A) may continue their mushrik way of life, no compulsion is imposed on them. Muslims would honor their pledge with them.
Those who broke the treaty (Group B) are further divided in two groups: those who don’t want to fight and seek Muslims’ protection, group B1, they are encouraged to become Muslims, yet they are free to continue to be mushrik if they so desire, and be protected by Muslims.
Those treaty brokers who still want to fight, group B2 is given a choice to either (i) repent and adhere to the treaty within 4 months, Or (ii) after four months, be ready to be fought, seized, and killed, until they desist to defame Islam, Or (iii) become Muslims, establish salat, pay zakah, as Muslims do, and become brothers in Deen. Thus, B2(iii) are not doing Salat and Zakah while in their state of idolatry, rather they have become Muslims by accepting the third choice (iii) out of three choices. There is no compulsion here either as some non-Muslims claim.