It is narrated from Sayyidah Aishah (may Allah be pleased with her) that the prayer first made obligatory was two rak'ahs. When the Prophet (peace and blessings be upon him) came to Madinah and settled, two rak'ahs were added, except for Maghrib, because it is witr (odd), and the morning prayer, because of its lengthy recitation. She said: When he (peace and blessings be upon him) travelled, he (peace and blessings be upon him) would pray his original prayer, that is, he would shorten it.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 1698