How did the Prophet (blessings and peace of Allah be upon him) know how to pray when he led the Prophets in prayer?
Question

When the Messenger of Allah (blessings and peace of Allah be upon him) led the Prophets in prayer during the Israa’ (Night Journey), how did he know how to pray?
Praise be to Allah.The fact that the Prophet (blessings and peace of Allah be upon him) led the Prophets in prayer on the night of the Israa’ is proven in saheeh hadiths.
In Saheeh Muslim (172) it is narrated: “Then I found myself among a group of the Prophets, and the time for prayer came, so I led them in prayer.” According to a report narrated by Ibn Jareer at-Tabari in his Tafseer (17/332): “Then we went on until we came to Bayt al-Maqdis [Jerusalem], where I led the Prophets and Messengers in prayer.” See: al-Israa’ wa’l-Mi‘raaj by al-Albani, p. 13.
Ibn Katheer said: The correct view is that he only met with them in the heavens, then he came back down to Bayt al-Maqdis, and they accompanied him, and he led them in prayer then. Then he rode on al-Buraaq and returned to Makkah.
End quote from Tafseer al-Quran al-‘Azeem (5/31).
There is no confusion about how the Prophet (blessings and peace of Allah be upon him) knew how to pray when he led the Prophets in prayer, because the prayer was enjoined upon the Muslims from the beginning of Islam. Hence, when Heraclius asked Abu Sufyaan: What does he enjoin upon you?
Abu Sufyaan said: He says: Worship Allah alone, and do not associate anything else with Him, and give up what your forefathers used to say; and he enjoins us to pray, give zakah, to be honest and chaste, and to uphold ties of kinship. Narrated by al-Bukhari (7).
Ibn Rajab said: This indicates that prayer was prescribed from the beginning of Prophethood, but the five daily prayers were not enjoined before the Israa’, and there is no difference of scholarly opinion concerning that.
End quote from Fath al-Bari (2/103).
And he said: The hadiths which indicate that the Prophet (blessings and peace of Allah be upon him) used to pray in Makkah before the Israa’ are many.
End quote. Fath al-Bari (2/102).
Ibn Hajar al-‘Asqallaani said: Before the Israa’, the Prophet (blessings and peace of Allah be upon him) used to pray irregularly, as did his companions.
End quote. Fath al-Bari (8/671).
This is indicated by the hadith of Zayd ibn Haarithah from the Prophet (blessings and peace of Allah be upon him), that Jibreel (peace be upon him) came to him when Revelation was first sent to him, and taught him how to do wudu and to pray. Narrated by Imam Ahmad in his Musnad (17026); classed as saheeh by al-Albani in as-Silsilah as-Saheehah (841).
An-Nawawi (may Allah have mercy on him) said: It is proven that our Prophet (blessings and peace of Allah be upon him) led all the Prophets (blessings and peace of Allah be upon them) in prayer on the night of the Israa’ in Bayt al-Maqdis. It may be that this prayer occurred before his ascent to heaven, or it may be that it happened after he came back down to earth.
The scholars differed concerning this prayer:
It was said that it was a verbal prayer, meaning that it was du`a and dhikr;
And it was said that it was the well-known prayer, and this view is more correct, because it is more appropriate to interpret the wording in the shar‘i sense than in the linguistic sense. Rather we interpret reports according to the linguistic meaning when it is not possible to interpret it according to the shar‘i meaning. But that is not an issue here, so we must interpret it as referring to the Islamically prescribed prayer.
Prayer was obligatory before the night of the Israa’, and it was obligatory to spend part of the night in prayer (qiyaam), as Allah, may He be glorified and exalted, stated in Soorat al-Muzzammil."(al-Masaa’il al-Manthoorah, p. 26)
See also the answer to question no. 145725
And Allah knows best.