Commentary :
There are rules and regulations for offering the prayer in congregation, that the Muslim should pay attention to and learn. One of the most important of these rules is following the imam properly.
In this hadith, the Prophet (blessings and peace of Allah be upon him) explains that the imam is only appointed to be followed, so the one who is praying behind the imam should follow his actions in prayer. Therefore the Prophet (blessings and peace of Allah be upon him) forbade those who are praying behind an imam to differ from the imam, which means doing the actions of prayer before him, or being too slow in following him, because differing from the imam means that one is no longer regarded as following him. Then the Messenger of Allah (blessings and peace of Allah be upon him) began to explain in detail, after speaking in general terms, how one should follow the imam. Hence he said: “When he bows, then bow.” The word fa, translated here as “then”, indicates that these actions should be done straight after the imam does them, and that the one who is praying behind the imam should not do them before the imam; rather every action that the one who is praying behind the imam does should be done after the imam does it. When the imam says after bowing, Sami‘a Allahu liman hamidah (Allah hears those who praise Him), then say Rabbana laka al-hamd (our Lord, to You be praise); what is meant is: O our Lord, to You be all praise. This is one of the greatest expressions of supplication and gratitude to Allah (may He be glorified and exalted). Based on that, it is sufficient for the one who is praying behind an imam to say the tahmid (Rabbana laka al-hamd) and not the tasmi‘ (Sami‘a Allahu liman hamidah) when rising from bowing. When the imam prostrates, then prostrate straight after he prostrates. And if he prays sitting, then pray sitting, all of you, for following the imam also means praying sitting if the imam prays sitting. Then the Messenger of Allah (blessings and peace of Allah be upon him) enjoined straightening the rows when praying, meaning that the people should stand in a straight line. This meaning also includes filling the gaps in the rows; the Prophet (blessings and peace of Allah be upon him) gave the reason for this command as being that making the rows straight is part of praying properly.
This hadith instructs the worshipper to follow the imam, and not do anything before he does it, or do something different to what he is doing. It also instructs the worshippers to straighten the rows when offering a congregational prayer..