All perfect praise be to Allaah, The Lord of the worlds. I testify that there is none worthy of worship except Allaah and that Muhammad, sallallaahu ‘alayhi wa sallam, is His slave and Messenger.
We do not know of any basis in the Sharia for the justification of the number of Rak'ahs mentioned in those stories; nothing had been reported to this effect in the Sunnah of the Prophet . Rather, some scholars mentioned those stories without their chain of narration. The Hanafi scholar Badr Ad-Deen Al-‘Ayni cited a similar account to what the questioner mentioned in his book Nukhab Al-Afkaar fi Tanqeeh Mabaani Al-Akhbaar fi Sharh Ma‘aani Al-Aathaar 3/350-351, the edition published by the Qatari Ministry of Awqaf. He cited on the authority of some scholars that the reason for performing the Fajr prayer as two Rak‘ahs was that our father Aadam (Adam), was the first to perform the Fajr prayer as two Rak‘ahs; that the Thuhr prayer was four Rak‘ahs because Prophet Ibraaheem (Abraham) was the first to perform it as such, and he mentioned the reason for performing it as four Rak‘ahs; and the that ‘Asr prayer is four Rak‘ahs because Prophet Yoonus (Jonah) was the first to perform it as such, and that the reason for performing it as four Rak‘ahs was that he was inside four layers of darkness: the darkness of his fault, the darkness of the deep sea, the darkness of the night, and the darkness of the whale’s stomach. He also mentioned that the first to perform the Maghrib prayer as three Rak‘ahs was ‘Eesa ibn Maryam (Jesus), and not Daawood (David), may Allaah exalt their mention, as the questioner mentioned. Also, the ‘Ishaa' prayer was performed by Moosa (Moses) and he mentioned the justification. Everything that he mentioned has no evidence in the Sharee'ah, as far as we know. However, such matters fall into the category of the knowledge that does not harm if one does not know it and does not benefit if one knows it. So do not waste your time in such matters any further.
For more benefit, please refer to fatwa 82181.
Allaah knows best.