When you offer the prayer, and you are in doubt about the number of rak'ahs whether offered three or four, and you have prayed four rak'ahs in all probability in your opinion, you should recite tashahhud and make two prostrations while you are sitting before giving the salutation. afterwards you should recite the tashahhud and give the salutation again. Abu Dawud said: This tradition has been narrated by 'Abd al-Wahid from Khusaif, but he did not report it as a statement of the Prophet ﷺ. The version of 'Abd al-Wahid has been corroborated by Sufyan, Sharik, and Isra'il. They differed amongst themselves about the text of the tradition and they did not narrate it with the continuous chain up to the Prophet ﷺ.
عَنْ رَسُولِ اللَّهِ ﷺ قَالَ إِذَا كُنْتَ فِي صَلاَةٍ فَشَكَكْتَ فِي ثَلاَثٍ أَوْ أَرْبَعٍ وَأَكْبَرُ ظَنِّكَ عَلَى أَرْبَعٍ تَشَهَّدْتَ ثُمَّ سَجَدْتَ سَجْدَتَيْنِ وَأَنْتَ جَالِسٌ قَبْلَ أَنْ تُسَلِّمَ ثُمَّ تَشَهَّدْتَ أَيْضًا ثُمَّ تُسَلِّمُ