The Prophet ﷺ used to pray on his mount facing eastward, but when he wanted to perform the obligatory prayer, he would dismount and face the qiblah.
حدثنا معاذ بن فضالة قال حدثنا هشام عن يحيى عن محمد بن عبد الرحمن بن ثوبان قال حدثني
أن النبي ﷺ كان يصلي على راحلته نحو المشرق فإذا أراد أن يصلي المكتوبة نزل فاستقبل القبلة