Prayer stands as the second pillar of Islam after testifying that there is no god but Allah and Muhammad is His final Messenger. The Prophet, peace and blessings be upon him, said, “Islam is built upon five pillars: testifying that there is no true god except Allah and that Muhammad is the Messenger of Allah, performing Salah, paying the Zakah, making the pilgrimage to the Sacred House (Hajj), and fasting the month of Ramadan.” (Al-Bukhari). There is nothing wrong if one repeats a Prayer as a nafl with a congregation even if one has already performed it, individually or with a congregation.
Sheikh Sayyed Sabiq states in his well-known book, Fiqh Us-Sunnah: Yazid Al-Aswad says: “We prayed Fajr Prayer with the Messenger of Allah (peace and blessings be upon him) at Mina and two men came and stopped at their resting places. The Prophet ordered for them to be brought and they came shaking with fear. The Prophet said to them, ‘What prevented you from praying with the people? … Are you two not Muslims?’ They answered, ‘Certainly we are, O Messenger of Allah, but we had prayed in our resting place.’ The Prophet told them, ‘If you pray in your resting places and then come upon an imam, pray with him, and it will be nafl for you’“ (Ahmad and Abu Dawud). An-Nasa’i and At-Tirmidhi record it in these words: “lf you pray in your resting places and then you come to a mosque with a congregation, pray with them, and it will be nafl for you.”
This hadith shows that it is correct for one to repeat a Prayer as a nafl with a congregation even if one has already performed it, individually or with a congregation.
It is related that Hudhayfah repeated the Zhuhr, `Asr, and Maghrib Prayers although he had prayed them in congregation. It is also related that Anas prayed Fajr behind Abu Musa at the place where fruits are dried and then he went to the congregational mosque and repeated the Prayer behind Al-Mughirah ibn Shu`bah.
Nevertheless, this action contradicts an authentic hadith of the Prophet (peace and blessings be upon him) in which he reportedly said, “Do not pray the same Prayer twice in one day.” The apparent conflict has been resolved by Ibn `Abdul-Barr who writes, “Ahmad and Ishaq agree that this refers to praying an obligatory Prayer and then, after a while, repeating it as the obligatory Prayer. Now, as for the one who repeats the Prayer with a congregation with the intention that the second Prayer is not a repeat of the obligatory Prayer but that it is simply a voluntary prayer, he obeys the Prophet’s order of not making the same Prayer twice, as the first Prayer was obligatory and the second was nafl; hence, there is no repetition.”