Salam Ustadh, when praying and you forget what rakat 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 u are not sure whether it the third or 4th rakah, take a moment, which ever your mind says is more likely (probable), u go with that.