Sunnah.com reference : Book 2, Hadith 309English translation : Book 2, Hadith 400Arabic reference : Book 2, Hadith 405
Narrated Yazid bin al-Aswad (RA):
He offered the morning prayer with Allah's Messenger (ﷺ) and when Allah's Messenger (ﷺ) finished his prayer, he saw two men who had not prayed with him. He ordered them to be brought and they were brought trembling with fear. He asked them what had prevented you from praying with us?" They said, "We had already prayed at our homes." He said, "Don't do so! If you pray at your homes and then you come while the Imam has not yet performed the prayer, you must pray with him, and it will be a voluntary prayer for you."

[Reported by Ahmad - with his wording - and ath-Thalathah. at-Tirmidhi and Ibn Hibban graded it Sahih (authentic)].
وَعَنْ يَزِيدَ بْنِ اَلْأَسْوَدِ ‏- رضى الله عنه ‏- { أَنَّهُ صَلَّى مَعَ رَسُولِ اَللَّهِ ‏- صلى الله عليه وسلم ‏-صَلَاةَ اَلصُّبْحِ, فَلَمَّا صَلَّى رَسُولُ اَللَّهِ ‏- صلى الله عليه وسلم ‏-إِذَا هُوَ بِرَجُلَيْنِ لَمْ يُصَلِّيَا, فَدَعَا بِهِمَا, فَجِيءَ بِهِمَا تَرْعَدُ فَرَائِصُهُمَا, فَقَالَ لَهُمَا: "مَا مَنَعَكُمَا أَنْ تُصَلِّيَا مَعَنَا?" قَالَا: قَدْ صَلَّيْنَا فِي رِحَالِنَا.‏ قَالَ: "فَلَا تَفْعَلَا, إِذَا صَلَّيْتُمَا فِي رِحَالِكُمْ, ثُمَّ أَدْرَكْتُمْ اَلْإِمَامَ وَلَمْ يُصَلِّ, فَصَلِّيَا مَعَهُ, فَإِنَّهَا لَكُمْ نَافِلَةٌ" }  رَوَاهُ أَحْمَدُ, وَاللَّفْظُ لَهُ, وَالثَّلَاثَةُ, وَصَحَّحَهُ اَلتِّرْمِذِيُّ, وَابْنُ حِبَّان َ  1‏ .‏‏1 ‏- صحيح.‏ رواه أحمد (4/160 و 161)‏، والنسائي (2/112)‏، وأبو داود (575)‏ و (576)‏، والترمذي (219)‏، وابن حبان (1564 و 1565)‏ وقال الترمذي: "حسن صحيح".‏ الفرائض: جمع فريضة، وهي اللحمة التي بين الجنب والكتف تهتز عند الفزع والخوف.‏ وقوله: "فلا تفعلا" قال ابن حبان: لفظة زجر مرادها ابتداء أمر مستأنف.‏