Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:2:239

And if you fear ˹an enemy, then pray˺ on foot or riding. But when you are secure, then remember Allah ˹in prayer˺, as He has taught you that which you did not ˹previously˺ know.  

And if you are in fear, of an enemy, or a torrent, or a predatory animal, then standing (rijāl, plural of rājil), praying while walking, or mounted (rukbān, plural of rākib). In other words, in whichever way you can, facing the direction of the qibla or otherwise, making the gestures of genuflexion and prostration; but when you are secure, from any fear, then remember God, by performing prayer, as He taught you what you knew not, before He taught you its obligations and its proper ways (the particle kāf ˹of ka-mā, ‘as’˺ has the same meaning as mithl ˹‘like’˺, while the mā is related to the verbal action, or is relative).
القرآن:٢:٢٣٩

فَإِنْ خِفْتُمْ فَرِجَالًا أَوْ رُكْبَانًا ۖ فَإِذَا أَمِنْتُمْ فَاذْكُرُوا اللَّهَ كَمَا عَلَّمَكُمْ مَا لَمْ تَكُونُوا تَعْلَمُونَ  

{فإن خفتم} من عدو أو سيل أو سبع {فرجالا} جمع راجل أي مشاة صلوا {أو ركبانا} جمع راكب أي كيف أمكن مستقبلي القبلة أو غيرها ويومئ بالركوع والسجود {فإذا أمنتم} من الخوف {فاذكروا الله} أي صلّوا {كما علمكم ما لم تكونوا تعلمون} قبل تعليمه من فرائضها وحقوقها والكاف بمعنى مثل وما مصدرية أو موصولة.