Yes, hadiths have been transmitted on this matter, but their chains of transmission are weak.
سئل الصادق ع لم صارت المغرب ثلاث رکعات و أربعا بعدها لیس فیها تقصیر فی حضر و لا سفر فقال إن الله تبارک و تعالى أنزل على نبیه ص کل صلاه رکعتین فأضاف إلیها رسول الله ص لکل صلاه رکعتين فی الحضر و قصر فیها فی السفر إلا المغرب و الغداه فلما صلى ع المغرب بلغه مولد فاطمه ع فأضاف إلیها رکعه شکرا لله عز و جل فلما أن ولد الحسن ع أضاف إلیها رکعتين شکرا لله عز و جل فلما أن ولد الحسین ع أضاف إلیها رکعتين شکرا لله عز و جل فقال للذکر مثل حظ الأنثیین فترکها على حالها فی الحضر و السفر
من لا یحضره الفقیه، ج1، ص: 454
Imam Jaʿfar al-Sadiq, peace be upon him, was asked, “Why is the evening prayer three rakʿahs, followed by four rakʿahs of its supererogatory prayer, with no shortening in either residence or travel?” He replied: “God, Blessed and Exalted, prescribed each prayer as two rakʿahs for His Prophet, peace and blessings be upon him and his family. In residence, the Messenger of God added two rakʿahs to each prayer, but on a journey he shortened them, except for the evening and dawn prayers. When the Prophet had performed the evening prayer, he received news of Fatima’s birth. In gratitude to God, Mighty and Glorious, he added one rakʿah to it. When al-Hasan was born, he added two rakʿahs in gratitude to God, Mighty and Glorious. And when al-Husayn was born, he added another two rakʿahs in gratitude to God, Mighty and Glorious. He said, ‘The male shall have the share of two females,’ and so he left it unchanged, both in residence and on a journey.”
In the commentary on *Man lā yaḥḍuruhu al-faqīh*, known as *Lawāmiʿ-e Ṣāḥibqarānī*, vol. 5, p. 62:
Imam Jaʿfar al-Sadiq, peace be upon him, was asked why the evening prayer consists of three rakʿahs, and why its four rakʿahs of supererogatory prayer are not shortened, whether one is at home or travelling. He replied that the Lord, Glorified and Exalted, initially prescribed the prayers for the Chief of the Messengers, peace and blessings be upon him and his family, as two rakʿahs each. The Prophet added two rakʿahs to each prayer when at home, while leaving them as they were when travelling, except for the evening and dawn prayers. When the Prophet had performed the evening prayer, he received news that the Lord, Glorified and Exalted, had bestowed Fatima upon him. In gratitude for this blessing, he added one rakʿah. When God, Glorified and Exalted, bestowed Imam al-Hasan upon him, the Messenger of God added two rakʿahs to the evening supererogatory prayer in gratitude to God, Glorified and Exalted. Then, when God, Glorified and Exalted, bestowed Imam al-Husayn, peace be upon him, upon him, the Prophet added another two rakʿahs to the evening supererogatory prayer in gratitude for this blessing. He recited the verse stating that God, Glorified and Exalted, has ordained that each son receive the share of two daughters. Since these were blessings for which gratitude was due, and since they were enduring blessings, he made the act of gratitude enduring too, leaving the prayer unchanged both at home and while travelling.