Ibn Abu Hatim related that Ibn `Abbas said that these people mentioned herein, were the residents of a village called Dawardan. `Ali bin `Asim said that they were from Dawardan, a village several miles away from Wasit (in Iraq).
In his Tafsir, Waki` bin Jarrah said that Ibn `Abbas commented,
(Did you (O Muhammad ) not think of those who went forth from their homes in thousands, fearing death) that they were four thousand persons who escaped the plague (that broke out in their land). They said, "We should go to a land that is free of death!" When they reached a certain area, Allah said to them:
In a uniquely eloquent manner, the two verses (243, 244) appearing above and verse 245 which follows, present guidance that prompts the sacrifice of one's life and possessions in the way of Allah Almighty. Consequently, before stating related injunctions, an important event of history has been taken up which makes it clear that death and life are subservient to the destiny determined by Allah. Going into a battle in jihad is not the cause of death, and running away from it, out of cowardice, is not the means to avoid death.
On the authority of revered Companions (Sahabah) and their successors (Tabi'in), Tafsir ibn Kathir explains this event as follows:
The Muslims left Makkah for Madinah as a result of severe persecution at the hands of the Makkans. In Madinah they were free to live in accordance with their religion. But the opponents of Islam did not leave matters at that. They began launching armed onslaughts on the Muslims in order to uproot them from Madinah. The Muslims at that time were far less in number and had fewer resources as compared to their opponents. This discouraged them from going ahead and facing the enemy. On this occasion God reminded them of an event in the history of the Israelites, where in the trials of life, fear of defeat was defeat itself. The Philistines, a neighbouring people, once attacked the Israelites and defeated them, slaying more than four thousand Hebrews. The Israelites were so greatly stricken with fear that they abandoned their homes and ran away. ‘Thus the glory departed from Israel,’ and in the words of the Bible, ‘All the houses of Israel trembled with fear and beseeched the Lord.’ Twenty years passed in this state. Then they all gave serious thought as to why they had been defeated by the Philistines. Their prophet Samuel said to them, ‘If you return to the Lord with all your hearts, then put away the foreign gods... from among you, and prepare your hearts for the Lord, and serve Him only; and He will deliver you out of the hand of the Philistines’ (1 Samuel 7:3). So they put away the foreign gods and served only their Lord. Now the Philistines drew near to battle against Israel, ‘But the Lord thundered on that day, with a great thunder upon the Philistines and discomfited them; and they were smitten before Israel’ (Samuel 7:10). Abandoning the path of trust in God leads to the moral death of nations and communities, while opting for the path of trust in God leads to their regeneration.
Uthmani text of the Madinah mushaf (King Fahd Complex). Translation: Saheeh International. Tafsir via Quran.com.