“Redeem, L-rd, Your people, the remnant of Israel, at every transition. May their needs be before You. Blessed are You, L-rd, Who listens to prayer.”
– Mishnah Berachos 4:4, sefaria.org
The Mishnah discusses fixed payer; and, the inability to pray a complete prayer, while walking in a place of danger. Fixed prayer, that is to say, prayer viewed as an obligation, whereof prayer may seem like a burden, and done only to fulfill an obligation is discouraged. For that type of prayer will not be sincere, as the person praying only seeks to relieve himself of what is considered a burdensome obligation.
In regard to prayer while traveling through an area that might be dangerous, it is assumed that the person’s mind is unsettled, hence, an inability to foster proper concentration. In this situation, a person is not required to say a complete prayer (e.g., the Shemonah Esrei). Moroever, there is not even a requirement to say Havineinu, a shortened version of the Shemonah Esrei; rather, an even briefer prayer may be recited (see above-mentioned prayer). Incidentally, I imagine that the reason the prayer is in the plural is because, prayers including oneself with others are more likely to be answered.
These considerations are made, for the sake of the safety of the traveler. Consider Moshe, who at the Sea of Reeds began to pray to H’Shem, when Pharaoh’s army posed a significant threat to B’nei Yisrael. To paraphrase the passage, H’Shem told Moses, now is not the time to pray; rather, I will deliver the people now. Certainly, in any given situation wherein imminent harm is at hand, the time would appear to be a time to act, rather than pray.
However, a brief prayer for deliverance is in total accord with what is right in the eyes of G-d, who would like us to put our trust completely in Him. At times like those, a brief prayer, like, “H’Shem, guard me against evil,” would be appropriate. The Mishnah, in discussing prayer here, Is only referring to traditional prayers recited on a daily basis, as opposed to impromptu heartfelt prayers that may be said at any time, in any situation.