The Messenger of Allah ﷺ said, "When one of you leads the people in prayer, let him keep it short, for among them are the elderly, the frail, and the sick. But when he prays alone, let him prolong his prayer as much as he wishes."
وقال رسول الله ﷺ إذا ما قام أحدكم للناس فليخفف الصلاة فإن فيهم الكبير وفيهم الضعيف وفيهم السقيم وإذا قام وحده فليطل صلاته ما شاء
This is a sahih hadith, narrated by Muslim, vol. 2, p. 43. Bukhari narrated it from Abu Zinad from Araj, vol. 1, p. 142. Abu Dawud narrated it from Qanabi and from Hasan bin Ali. Tirmidhi narrated it from Qutayba, and also through him. Nasai narrated it from Qutayba as well. Malik narrated it in Muwatta from Abu Zinad.This hadith contains an instruction for the imam to shorten the prayer, provided that this does not compromise its established practices and purposes. It also indicates that when he prays by himself, he may lengthen the pillars that admit of lengthening as much as he wishes, namely standing, ruku, and sujud, and the tashahhud, but not the brief standing after ruku or the sitting between the two prostrations.It also contains evidence for showing gentleness toward the believers and the rest of the followers, and for taking their welfare into consideration.Muslim also narrated with his chain from Anas bin Malik, who said, the Messenger of Allah ﷺ said, "I enter the prayer intending to lengthen it, then I hear a child crying, so I shorten it out of concern for the intensity of his mother's distress over him."