The Fear prayer has different forms; it is performed as follows:
The Prophet (saws) stands as Imam, the first group pray with him, whereas the second group watching the enemy to protect the prayers from any sudden attach, then when the first Rek’a completed, this second group comes and stands to pray the second Rek’a. In this case bother of the groups would have prayed behind the Prophet (saws). But the question is why do they hold their arms while they are in Allhs’s protection and the Prophet (saws) was with their Imam and Allah (swt) says:
إِن يَنصُرْكُمُ اللَّهُ فَلَا غَالِبَ لَكُمْ
(If Allah should aid you, no one can overcome you;) (Ali-Imran: 160)
The answer is: Allah (swt) had established ways in the universe and put means in this life, and connect the means with the results, so that if you do not take the required means you do not have to right to say this is my destiny. For example, if there is a car moving with high speed and a man threw himself in its way and consequently, he passes away, in this case it is true that he died because of what he has done but it is his destiny to die at that moment. In other words, Allah’s (swt) put reasons and orders the humans to follow the means and the evidence is the Fear prayer; despite the presence of the Messenger (saws) with them, Allah (swt) commanded them to take their weapons and take precaution so that He (swt) teaches people not to abandon the causes that He (swt) has created and to abide by them.