During a recent trip we stopped to pray Maghrib in a mosque, and after completing the prayer, several people wanted to pray Isha. As they started their prayer, others came in and joined them thinking that it was a congregation for Maghrib prayer. How could this happen? What should these latecomers do in order to finish their Maghrib prayer properly?
There is no problem with a difference of the prayers offered by different people in the same congregation. Thus the imam may be praying Asr and you want to offer your Dhuhr prayer, there is no problem with that. You may be praying Isha, while the imam is doing his Maghrib. Both prayers are correct and acceptable.
The problem in the case you have cited results from the fact that Isha is offered normally in 4 rak’ahs while Maghrib is 3 rak’ahs. Thus, a person who joins the congregation at the beginning or during the first Rak’ah finds himself in a difficult position when the imam stands for his fourth Rak’ah. That person cannot finish his prayer on his own, because that invalidates his prayer, and he cannot continue with the imam because he would be adding to his prayer what he cannot add. There are two ways to deal with this situation.
The first is that if the person offering Maghrib prayer comes at the beginning and knows that the imam will be praying four rak’ahs, he should delay his own start with the congregation until the imam stands up for his second Rak’ah. He then joins the congregation and completes his prayer with the imam. There will be a difference in his prayer from its normal course, but this does not affect its validity. The second is that if a person joins the congregation in its first Rak’ah, offering Maghrib and thinking that the congregation is offering the same prayer. He is then surprised to find out that the imam stands up for a fourth Rak’ah. In this case, he does not join the fourth Rak’ah, but sits down in the position we normally take for Tashahhud, waiting for the imam to finish his fourth Rak’ah and sits to conclude the prayer. When the imam concludes, he concludes with him.