وَمَنْ شَكَّ فِي صَلَاتِهِ، فَلَمْ يَدْرِ أَثَلَاثًا صَلَّى أَمْ أَرْبَعًا؟ وَذَلِكَ أَوَّلُ مَا عَرَضَ لَهُ: اسْتَأْنَفَ الصَّلَاةَ،
Translation: If one doubts whether three or four rakahs were performed, and it is the first such occurrence, one starts the prayer anew.
First occurrence refers to an unfamiliar incident of uncertainty. The cited ruling is to restart the prayer.
This is distinguished from frequent recurring doubt, where repeatedly restarting is not the intended legal approach.