Salam Ustadh, when praying and you forget what rak’ah you are on or how many you have prayed, what should you do?
Go with what is most likely in your mind.
If you are completely 50/50 (very unlikely) repeat the prayer. If this happens regularly, there’s another solution but I’m hoping it’s not regular and your mind can always settle on the most like of two possibilities.
So, for example, if you are not sure whether it the third or the fourth rak’ah, take a moment, and which ever your mind says is more likely (probable), you go with that.