A man came to the Prophet ﷺ and said: O Messenger of Allah ﷺ, I prayed but I do not know whether I did an even number [of rakʿahs] or an odd number. The Messenger of Allah ﷺ said: ʿBeware lest the Shaitan toy with you in your prayer. Whoever among you prays and does not know whether he did an even number [of rakʿahs] or an odd number, let him prostrate twice, for that will complete his prayer.ʿ It was narrated that Masarrah bin Maʿbad said: Yazeed bin Abi Kabshah led us in praying ʿAsr, then he turned to us after the prayer and said: I prayed with Marwan bin al-Hakam and he did two prostrations like these, then he turned to us and told us that he prayed with ‘Uthman ؓ , who narrated from the Prophet ﷺ ... and he mentioned a similar report.
جَاءَ رَجُلٌ إِلَى النَّبِيِّ ﷺ فَقَالَ يَارَسُولَ اللهِ إِنِّي صَلَّيْتُ فَلَمْ أَدْرِ أَشَفَعْتُ أَمْ أَوْتَرْتُ فَقَالَ رَسُولُ اللهِ ﷺ إِيَّايَ وَأَنْ يَتَلَعَّبَ بِكُمُ الشَّيْطَانُ فِي صَلاتِكُمْ مَنْ صَلَّى مِنْكُمْ فَلَمْ يَدْرِ أَشَفَعَ أَوْ أَوْتَرَ فَلْيَسْجُدْ سَجْدَتَيْنِ فَإِنَّهُمَا تَمَامُ صَلاتِهِ