(a) Sa'id bin al-Musayyib (may Allah have mercy on him) said: The Sunnah, when a man catches one rak'ah of the Maghrib prayer with the imam, is that he sit with the imam for the final sitting; when the imam says the salam, he stands and prays the second rak'ah and sits for the tashahhud, then he stands and prays the third rak'ah and recites the tashahhud in it, and then says the salam. The other prayers in which one sits follow this same method.
(b) Imam al-Zuhri (may Allah have mercy on him) said that Sa'id bin al-Musayyib (may Allah have mercy on him) said: Tell me, which prayer is it in which the tashahhud is recited three times in three rak'ahs? When he was asked about it, he said: It is the Maghrib prayer, when a man misses one rak'ah of it; then he recites the tashahhud in the other rak'ahs he catches with the imam, and he also recites the final tashahhud.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 3634