The Messenger of Allah ﷺ led the people in offering the fear prayer, two rak'ahs. Then he said the taslim and led others in offering the fear prayer, then he said the taslim. So the Prophet ﷺ had prayed four rak'ahs. (Using translation from Nasāʾī 1551)
أَنَّ رَسُولَ اللهِ ﷺ «صَلَّى بِالْقَوْمِ فِي الْخَوْفِ رَكْعَتَيْنِ ثُمَّ سَلَّمَ ثُمَّ صَلَّى بِالْقَوْمِ الْآخَرِينَ رَكْعَتَيْنِ ثُمَّ سَلَّمَ فَصَلَّى النَّبِيُّ ﷺ أَرْبَعًا» خَالَفَهُ يُونُسُ بْنُ عُبَيْدٍ