These verses refer to the battle of Khandaq (Ditch, trench), or better known as the battle of Ahzab (Tanwir al-Miqbas min Tafsir Ibn ‘Abbas). The Quraysh wanting to get rid of the Islam and Muslims once and for all mustered 1000s of troops, this is not including the help of other tribes in Arabia.
They went on an offensive and attacked Madinah – home of the Muslims. With news reaching the Prophet (p) on what they were up-to, he along with his Companions dug a trench around Madinah, so as to make it difficult for enemies to enter Madinah.
33:15 And they had already promised Allah before not to turn their backs and flee. And ever is the promise to Allah [that about which one will be] questioned.
33:18 Already Allah knows the hinderers among you and those [hypocrites] who say to their brothers, “Come to us,” and do not go to battle, except for a few,
33:20 They think the companies have not [yet] withdrawn. And if the companies should come [again], they would wish they were in the desert among the bedouins, inquiring [from afar] about your news. And if they should be among you, they would not fight except for a little.
33:23 Among the believers are men true to what they promised Allah . Among them is he who has fulfilled his vow [to the death], and among them is he who awaits [his chance]. And they did not alter [the terms of their commitment] by any alteration –
33:25 And Allah repelled those who disbelieved, in their rage, not having obtained any good. And sufficient was Allah for the believers in battle, and ever is Allah Powerful and Exalted in Might.
33:26 And He brought down those who supported them among the People of the Scripture from their fortresses and cast terror into their hearts [so that] a party you killed, and you took captive a party.
33:27 And He caused you to inherit their land and their homes and their properties and a land which you have not trodden. And ever is Allah, over all things, competent.
33:15 – This verse refers to a treaty that was set in Madinah with the Jewish tribes that they would help and aid the Muslims if an outside enemy were to attack the city. Instead they abandoned all their obligations and aided the enemy (Tanwir al-Miqbas min Tafsir Ibn ‘Abbas).
33:18 – There were some double-faced Muslims, the hypocrites who would tell believers not to help other Muslims out in defending the city from being attacked by the Quraysh. Even when they did go out in battle, they did so for fame (Tafsir al-Jalalayn and Tanwir al-Miqbas min Tafsir Ibn ‘Abbas)
33:20 – The hypocrites who feared the Quraysh would say among themselves, that the enemy Quraysh didn’t depart back to Makkah after the defeat they suffered. The verse highlights even if the Quraysh enemy were to come a second time they would wish they would not be in Madinah defending the community.
Instead they yearned to be with others in other parts of Arabia. Even if they were among the believers and an enemy were to hurt the Muslims, many of the hypocrites wouldn’t fight, except few.
33:23 – Here in the verse God states that the true believers are the companions of Prophet Muhammed, who always stood steadfast alongside the Messenger in whatever situation they were in. They never lost sight nor broke any promise. Some of them have become martyrs for defending their community from tyranny and oppression of the Quraysh.
God highlights that these are the true Muslims, unlike the hypocrites who would back-stab, never commit to anything they say (Tafsir al-Jalalayn, Tanwir al-Miqbas min Tafsir Ibn ‘Abbas and Asbab Al-Nuzul by Al-Wahidi).
33:25 – God Almighty drove back the confederates, defeated them. It speaks of those enemies of the believers who attacked Madinah and tried to get rid of Islam and Muslims once and for all (Tafsir al-Jalalayn, Tanwîr al-Miqbas min Tafsir Ibn ‘Abbas and Tafsir Ibn Kathir). 
33:26 This present verse speaks of events that occurred just after the Quraysh enemy and their allies retreated. The verse shows that some of those ‘supposed’ allies who made a pact with the Muslims, that they wouldn’t ally them themselves with any enemy. Instead, we are told that the Banu Qurayzah helped and armed the enemies in defeating the Muslims. The verse speaks about those who were found to be guilty of treachery.
That a party among them were killed and a party spared because they weren’t involved in this (Tafsir al-Jalalayn, Tafsir Ibn Kathir and Tanwir al-Miqbas min Tafsir Ibn ‘Abbas). For more detailed discussion on the Banu Qurayzah’s treachery, please click on the following link: “Re-Examining Banu Qurayzah Incident”
33:27 – According to exegesis on the Quran, this verse refers to Khaybar. After the people of Khaybar sided with the Quraysh, helped them, instigated wars and fought against the Muslims, when in last they were dealt with they asked the Prophet (p) to spare their lives. Prophet Muhammed (p) took away their rights to their land since they were a people who caused wars, but allowed them to stay on there as long as they stayed peaceful (Tafsir Jalalayn and tafsir Ibn kathir).
Dr. Muhammad Asad:
“20 Lit., “and would not have tarried more than a little [while]”.
21 Lit., “for then” or “in that case” (idhan), signifying here “however it may be”.
22 Sc., “but would come back in force and resume the siege”.
23 Lit., “‘they would not fight except a little”.
24 This verse (and the passage that follows) connects with verses 9-11 above, and especially with verse 11 – “there and then were the believers tried, and shaken with a shock severe” – which summarizes, as it were, their experiences during the critical days and weeks of the War of the Trench.
Although it is addressed, in the first instance, to those early defenders of Medina who were thus exhorted to emulate the Prophet’s faith, courage and steadfastness, the above verse is timeless in its import and its validity for all situations and conditions. –
Since the verb rajawa, as well as the noun-forms rajw, rujuww and raja’ derived from it, carry the connotation of both “hope” and “fear” (or “awe”), I have rendered yarju accordingly. 25 These seem to be allusions to 29:2 (which may have been one of the last Meccan revelations) as well as to 2:155 and 214 (i.e., verses of the first surah of the Medina period).
26 Specifically, this verse is said to apply to certain of the Companions who vowed, at the time of the early campaigns, that they would fight until death at the Prophet’s side (Zamakhshari); in its wider sense, however, it relates to all efforts involving a supreme sacrifice in God’s cause.
27 Cf. 6:12 – “God, who has willed upon Himself the law of grace and mercy” – and the corresponding note 10.
28 I.e., the pagans among the Confederates (see note 13 above); their Jewish allies are mentioned separately in the next verse.
29 Lit., “them”, i.e., the tribes allied against Muhammad and his community. The “followers of earlier revelation” (ahi al-kitab) referred to here were the Jews of the tribe of Banu Qurayzah, who despite their monotheistic faith had betrayed the Muslims and made common cause with the pagan Confederates.
After the dismal rout of the latter, the Banu Qurayzah, anticipating the vengeance of the community which they had betrayed, withdrew to their fortresses in the vicinity of Medina. After a siege lasting twenty-five days they surrendered to the Muslims, forfeiting all that they possessed.” 
Malik Ghulam Farid:
“2340. The words refer to the treaty which the Jews of Medina had made with the Holy Prophet that they would fight on his side against any enemy who invaded Medina.
2341. Shuh meaning both niggardliness and greed, the expression means, (a) that the hypocrites are very niggardly in giving help to the Muslims; (b) that they are very greedy of getting money, and taunt the Muslims if their greed is not satisfied.
2342. With the 13th verse the description had begun of an hypocrite’s state of mind, particularly when he is face to face with danger. The picture has become complete with the present verse. The hypocrite is a coward and a defeatist. He is a liar and has no regard for pledges solemnly made.
He is treacherous, disloyal and perfidious. He is niggardly and greedy. In short, he is the complete antithesis of a true believer. …
2344. The reference is to the Prophecy about the defeat and discomfiture of the hosts of disbelief and the victory of Islam (38:12 & 54:46). …
2346. Allah repelled the attack of the confederates. They had to raise the siege and, consumed with anger and rage at having completely failed in their unholy and nefarious undertaking, they went back to their homes, never being in a position again to attack Medina. Henceforward the initiative passed into the hands of Muslims.
The battlE of the Trench marked a turning point in the history of Islam. From a weak and continuously harassed and harried minority Islam became a mighty force in Arabia.
2347. The perfidious Banu Quraizah had entered into a solemn treaty with the Holy Prophet that they would help Muslims if an enemy attacked Medina. But at the time of the Battle of the Trench they were prevailed upon by Huyayy, the leader of the Banu Nadir to break their plighted word and join the grand confederacy against Islam. When the attack fizzled out, the Holy Prophet marched against them, and besieged them in their strongholds.
The siege continued for about 25 days after which they agreed to lay down their arms and preferred to submit to the award of Sa’d bin Mu’adh, the chief of the tribe of Aus, rather than to that of the Holy Prophet. Sa’d decided the case according to the Mosaic Law (Deut: 20:10-15).” 
Maulana Muhammad Ali:
“14a. These verses describe the condition of the hypocrites, who advanced excuses for not fighting against the opponents of the Muslims. If an enemy had entered into the city from another side and invited them to join hands with him to fight against the Muslims, they would have been ready to fight. The concluding words show that they would have even left Madinah to attack the Muslims and would not then have cared for the protection of their houses.
This verse points to a most significant truth and a distinguishing characteristic of the Holy Prophet, viz., that he is the best exemplar and the highest model of virtue for the faithful under all circumstances. If he had not led armies, he could not have served as a model for a general leading armies into battle; if he had not fought personally,
He could not have been an exemplar for a soldier laying down his life in the cause of truth, justice, and freedom; if he had not made laws for the guidance of his followers, he could never have been regarded as an outstanding example to a legislator; if he had not decided cases, he could not have served as a light to judges and magistrates;
if he had not married, he would have left men unguided in practically half of their everyday duties and could not have shown how to be a kind and affectionate husband and a loving father; if he had not taken revenge on tyrants for the wrongs inflicted on innocent persons, if he had not overcome his persecuting enemies and forgiven them,
if he had not overlooked the faults of those attached to him, he could not have been an excellent exemplar and a perfect model, as he is here pronounced to be. Indeed, it is the distinguishing characteristic of his life that he not only gave practical rules of guidance in all walks of life, but gave by his life a practical illustration of all those rules.
Two more points are worth noting here. In the first place, the Prophet’s being an exemplar is a sufficient answer to all those who carp at him, because the very necessity of guiding men under varying mundane circumstances and conditions led him through all those circumstances.
Secondly, the moral qualities which are latent within man remain in a dormant condition unless they are called into action. Hence no one can claim the possession of a high moral quality unless he has had occasion to display it, acquitting himself creditably.
The occasion on which the Prophet’s being an exemplar for the faithful is pointed out is one on which he showed the greatest firmness in utmost danger, confidence in Divine assistance, and steadfastness in the hardest trials, and the believers are told that they must not lose heart, but follow the example of the Holy Prophet.
22a. The reference here is to the Divine promise that a time would come when the combined forces of Arabia would be put to flight. This promise was given long before, and at a time when the Holy Prophet and his few followers were being severely persecuted at Makkah. Here are the words of one prophecy: “What an army of the allies is here put to flight” (38:11); “Soon shall the hosts be routed and they will show their backs” (54:45), says another.
So when the combined forces attacked Madinah, the words of the prophecy were in the heart of every true Muslim. They rejoiced because they were certain that the combined forces of the enemy would be put to flight. It was only the hypocrites who had misgivings, as the last section shows.
The battle had, in fact, inspired greater faith in the ultimate triumph of Islam, not only by bringing earlier prophecies to fulfilment but also because it was here that, when the Holy Prophet smashed a big stone with a hammer (a stone which had proved an obstacle in the digging of the ditch) and a flash of light followed, he announced the mighty prophecy
that the flash of light had revealed to him the palaces of the Chosroes and the Caesars, and that he had been informed that his followers would be triumphant over both the empires (Ah. IV, p. 303).
23a. Some of the believers had become martyrs in the cause of truth; others yet waited, anxious to lay down their lives in the same cause.
24a. It is clearly stated here, as also in v. 17, that all the hypocrites would not be punished, but that Allah would be merciful to them, punishing only such as deserved to be punished. Thus it happened that most of them became afterwards sincere converts to Islam.
26a. The Bani Quraizah were in alliance with the Holy Prophet, and when the enemy laid siege to Madinah, they were bound to repel the attack; see 2:84a. Instead of this they sided with the invading army. Muir admits that “it was agreed that the Quraizah would assist the Quraish”, and though he doubts whether “they entered on active hostilities”, there is the surest testimony that they had made an agreement with the Quraish to attack the Muslims from within.
Therefore, when the besieging army took to flight and the Quraizah returned to their fortress, it was besieged by the Holy Prophet, for to leave such an internal enemy unpunished would have been a source of ever-present danger to the safety of the Muslim community.
They remained besieged for twenty-five days, and then expressed their willingness to surrender, on condition that they should submit to the sentence of punishment pronounced by Sa‘d ibn Mu‘adh. Had they trusted the Prophet, he would probably have given them the same punishment as he gave to the Qainuqa’, viz., emigration, but Sa‘d was exasperated by their treachery and his judgment was that the fighting men should be put to death and the rest made captives (B. 56:168).
This was in accordance with the Jewish Law: “And if it will make no peace with thee, but will make war against thee, then thou shalt besiege it. And when the Lord thy God hath delivered it into thine hands, thou shalt smite every male thereof with the edge of the sword.
But the women, and the little ones, and the cattle, and all that is in the city, even all the spoil thereof, shalt thou take unto thyself” (Deut. 20:12 – 14). Three hundred men suffered death under this sentence, and their lands fell into the hands of the Muslims.
27a. The land which you have not yet trodden refers to the foreign lands which are here promised to the Muslims and which they conquered later.” 
 “On the day of Al-Khandaq the idolators kept us from praying Zuhr until the sun had gone down; that was before the revelation concerning fighting was revealed. Then Allah, the Mighty and Sublime, revealed: Allah sufficed for the believers in the fighting.
The Messenger of Allah commanded Bilal to say the Iqamah for Zuhr prayer, and he offered it just as he used to offer it on time. Then he said the Iqamah for ‘Asr and he offered it just as he used to offer it on time. Then he called the Adhan for Maghrib and offered it on time.” Al-Ahzab 33:25.” (Sunan an-Nasa’i volume 1, Book 7, Hadith 662)
 The Message of The Quran translated and explained by Muhammad Asad, page 891 – 893
 The Holy Qur’an – Arabic Text With English Translation & Short Commentary By Malik Ghulam Farid, Page 849 – 852
 The Holy Quran Arabic Text with English Translation, Commentary and comprehensive Introduction by Maulana Muhammad Ali, page 827 – 831