The Messenger of Allah ﷺ used to perform voluntary prayers on his mount, facing whichever direction it was headed, and he would pray the witr on it as well. However, he would not perform the obligatory prayers on it.
حدثنا أحمد بن صالح حدثنا ابن وهب أخبرني يونس عن ابن شهاب
كان رسول الله ﷺ يسبح على الراحلة أي وجه توجه ويوتر عليها غير أنه لا يصلي المكتوبة عليها
Muslim narrated it in the chapter on the prayer of travelers, section on the permissibility of performing the voluntary prayer while riding, in whatever direction one faces during travel, hadith no. 700/39, from the hadith of Abdullah bin Wahb. Bukhari also narrated it, in the chapter on shortening the prayer, section titled "He dismounts for the obligatory prayer," hadith no. 1098, from the hadith of Yunus bin Yazid, with the same wording.