This verse was revealed concerning the battle of Uhud (Tafsir Ibn Kathir Asbab Al-Nuzul by Al-Wahidi, Ruhul Ma’ani, and Tafsir Anwarul Bayan). This battle ensued as a consequence of Quraysh getting defeated at the battle of Badr. Hence, the Quraysh promised to come back the following year to fight the Muslims.
For more information on the battle of Uhud, please click on the following article: “The Battle Of Uhud – Quraysh Declared War“.
“Indeed, Allah loves those who fight in His cause in a row as though they are a [single] structure joined firmly.” – Quran 61:4
61:4 – The believers were tested in the day of Uhud, 1400 years ago. God loves the believers to fight in straight row as a solid structure. Instead of following this command, some of the Muslims retreated and fled, leaving Prophet Muhammed behind (Tafsir Ibn Kathir).
Maulana Muhammad Ali:
“4a. They had to fight in self-defence; see 2:190, 190a, etc.” 
Dr. Muhammad Asad:
“2 I.e., in unison, with their deeds corresponding to their assertions of faith. This moral necessity is further illustrated – by its opposite – in the subsequent reference to Moses and the recalcitrant among his followers.” 
Islamic scholar Abdullah Yusuf Ali:
“5433 A battle array, in which a large number of men stand, march, or hold together against assault as if they were a solid wall, is a striking example of order, discipline, cohesion, and courage. A solid cemented structure is even a better simile than the usual ‘solid wall’ as the ‘structure’ or building implies a more diversified organisation held together in unity and strength, each part contributing strength in its own way, and the whole held together not like a mass but like a living organism. Cf. also 31:1 and n. 4031.” 
Shaykh Ashiq Ilahi Madni:
“‘WHY DO YOU SAY THAT WHICH YOU DO NOT DO’
Sayyidina Abdullah bin Salam narrates that a few Prophet’s companions (sahabah) were sitting together speaking about good deeds when they said that if they knew which deed pleased Allah most, they would carry it out. It was then that Allah revealed the verse, ‘Whatever is in the heavens and whatever is on the earth glorifies Allah. He is the Mighty, the Wise. O you who believe! Why do you say that which you do not do?’ [Tirmidhi, chapter of Tafsir]
‘Ma’alimut Tanzil’ reports that Allah Ta’ala revealed the verse ‘Verily Allah loves those who fight in His rows as if they are a solid building’ when the Prophet’s companions (sahabah) said that if they knew what deed was most beloved to Allah, they would carry out the deed and spend their lives and all their wealth for the same. Shortly after they said this, the Battle of Uhud took place and many of them were found lacking in their resolve. It was then that Allah revealed the verse ‘O you who believe! Why do you say that which you do not do?’ Some commentators state that when the Prophet’s companions (Sahabah) heard about the rewards that the martyrs of Badr received, they said, ‘If we are afforded the opportunity to fight in Jihad, we would fight with all our might.’
However, when they were forced to flee from the battlefield during the Battle of Uhud, Allah chided them with the verse: ‘O you who believe” Why do you say that which you do not do?’
‘Ruhul Ma’ani’ reports from Sayyidina Ibn Zaid that the verse refers to the hypocrites who promised their assistance to the Muslims but failed to honour their promise.” 
Asbab Al-Nuzul by Al-Wahidi:
“(All that is in the heavens and all that is in the earth glorifieth Allah, and He is the Mighty, the Wise) [61:1-4]. … said: “We sat — a group of Companions of the Messenger of Allah, Allah bless him and give him peace — and reminded each other. We said: ‘If only we knew the most beloved works to Allah, glorified and exalted is He, for we would then perform them’. Allah, exalted is He, therefore, revealed (Lo! Allah loveth them who battle for His cause in ranks, as if they were a solid structure) [61:4] up to the end of the Surah. The Messenger of Allah, Allah bless him and give him peace, read it to us”. (O ye who believe! Why say ye that which ye do not?) [61:2-4]. The commentators of the Qur’an said: “Some Muslims used to say: ‘If we knew the most beloved works to Allah, exalted is He, we would spend our wealth and persons in their sake’. And so Allah, exalted is He, directed them to the most beloved works to Him, saying (Lo! Allah loveth them who battle for His cause in ranks, as if they were a solid structure…) But when Muslims were tested at the Battle of Uhud, they retreated, and so Allah, exalted is He, revealed (O ye who believe! Why say ye that which ye do not?)”. (Asbab Al-Nuzul by Al-Wahidi on Surah 61:4 – online Source)
Tafsir Ibn Kathir
“…(Verily, Allah loves those who fight in His cause in rows) Allah stated what He likes, and they were tested on the day of Uhud. However, they retreated and fled, leaving the Prophet behind. It was about their case that Allah revealed this Ayah: (O you who believe! Why do you say that which you do not do) Allah says here, `The dearest of you to Me, is he who fights in My cause.”’ Some said that it was revealed about the gravity of fighting in battle, when one says that he fought and endured the battle, even though he did not do so. Qatadah and Ad-Dahhak said that this Ayah was sent down to admonish some people who used to say that they killed, fought, stabbed, and did such and such during battle, even though they did not do any of it. Sa`id bin Jubayr said about Allah’s statement, (Verily, Allah loves those who fight in His cause in rows (ranks)) “Before Allah’s Messenger began the battle against the enemy, he liked to line up his forces in rows; in this Surah, Allah teaches the believers to do the same.” He also said that Allah’s statement, (as if they were a solid structure.) means, its parts are firmly connected to each other; in rows for battle. Muqatil bin Hayyan said, “Firmly connected to each other.” Ibn `Abbas commented on the meaning of the Ayah, (as if they were a solid structure.) by saying, “They are like a firm structure that does not move, because its parts are cemented to each other.” (Tafsir Ibn Kathir on Surah 61:1-4 – Online source)
Don’t forget to follow Discover The Truth on Facebook and Twitter. PLEASE help spread the word by sharing our articles on your favourite social networks.
 The Holy Quran Arabic Text with English Translation, Commentary and comprehensive Introduction [Year 2002 Edition] by Maulana Muhammad Ali, page 1087
 The Message of The Quran translated and explained by Muhammad Asad, page 1169
Click to access The_Message_of_The_Quran__by_Muhammad_Asad.pdf
 The Meaning Of the Glorious Qur’an: Text, Translation, and Commentary by Abdullah Yusuf Ali, page 400
Click to access quran-yusuf-ali.pdf
 Illuminating Discourses on the Noble Quran – Tafseer Anwarul Bayan – By Shaykh Ashiq Ilahi Madni (r.a), volume 5, page 173 – 174