It is easy to cut and paste without reading the whole surah to understand. A group of pagans made an agreement with the Muslims that they would be allowed to do Hajj. The Muslims did as the agreement asked but the Pagans repeatedly denyed them the right to do Hajj and blocked them even though they had furfilled there part of the bargan. So they were given a warning over a period of of time and then if they did not allow them to do Hajj than they were given permission to fight the pagens who had violated the agreement. But were clearly told not to harm those who had not violated the agreements. In Islam at the time Muslims were forbidden to fight without permission. This was permission to go to war.
A (declaration) of immunity from Allah and His Messenger, to those of the Pagans with whom ye have contracted mutual alliances
Go ye, then, for four months, backwards and forwards, (as ye will), throughout the land, but know ye that ye cannot frustrate Allah (by your falsehood) but that Allah will cover with shame those who reject Him.
And an announcement from Allah and His Messenger, to the people (assembled) on the day of the Great Pilgrimage,- that Allah and His Messenger dissolve (treaty) obligations with the Pagans. If then, ye repent, it were best for you; but if ye turn away, know ye that ye cannot frustrate Allah. And proclaim a grievous penalty to those who reject Faith.
(But the treaties are) not dissolved with those Pagans with whom ye have entered into alliance and who have not subsequently failed you in aught, nor aided anyone against you. So fulfil your engagements with them to the end of their term: for Allah loveth the righteous
But when the forbidden months are past, then fight and slay the Pagans wherever ye find them, an seize them, beleaguer them, and lie in wait for them in every stratagem (of war); but if they repent, and establish regular prayers and practise regular charity, then open the way for them: for Allah is Oft-forgiving, Most Merciful.
If one amongst the Pagans ask thee for asylum, grant it to him, so that he may hear the word of Allah; and then escort him to where he can be secure. That is because they are men without knowledge.
How can there be a league, before Allah and His Messenger, with the Pagans, except those with whom ye made a treaty near the sacred Mosque? As long as these stand true to you, stand ye true to them: for Allah doth love the righteous. .