The Messenger of Allah ﷺ said: "When any one of you gets up and prays, the Shaitan comes to him an confuses him until he does not know how many (Rak'ahs) he prayed. If any one of you notices that, let him prostrate twice when he is sitting." (Using translation from Nasāʾī 1252)
سَمِعْتُ رَسُولَ اللَّهِ ﷺ يَقُولُ «يَأْتِي الشَّيْطَانُ أَحَدَكُمْ وَهُوَ فِي صَلَاتِهِ لِيُلْبِسَ عَلَيْهِ حَتَّى لَا يَدْرِيَ كَمْ صَلَّى فَإِذَا وَجَدَ أَحَدُكُمْ ذَلِكَ فَلْيَسْجُدْ سَجْدَتَيْنِ وَهُوَ جَالِسٌ»