Praise be to Allah.
If the worshipper is not sure how many rak‘ahs of the prayer he has done, he should assume it is the lower number and complete his prayer on that basis, then do the prostration of forgetfulness before saying the tasleem. If he is not sure during the rak‘ah whether it is the first and second, he should regard it as the first and complete his prayer on that basis, praying three rak‘ahs after that, then he should do the prostration of forgetfulness before saying the tasleem.
See the answer to question no. 33624.
If a Muslim offers a prayer that is not correct because he does not know the rulings on prayer, and he continues to do that for a while, then the correct scholarly view is that he does not have to make up past prayers. Rather he should only repeat the last prayer if there is still time for it and its time has not ended.
The evidence for that from the Sunnah is the hadeeth of the man who used to pray badly and did not do it at a measured pace. The Prophet (blessings and peace of Allah be upon him) did not instruct him to make up his past prayers; rather he only instructed him to repeat the last prayer.
Shaykh al-Islam Ibn Taymiyah (may Allah have mercy on him) said:
He (blessings and peace of Allah be upon him) did not instruct him to repeat whatever prayers he had offered before that, even though he said: I cannot do better than that. Rather he instructed him to repeat that particular prayer because there was still time left for it, and he was enjoined to offer the prayer during its time. That was the prayer that he had not offered properly and there was still time for that prayer. It is well known that if a child reaches puberty or a kaafir becomes Muslim or a menstruating woman becomes pure or an insane person comes to his senses, and there is still time left for a prayer, they should offer it, because that is the right time for it, and it is not to be regarded as making it up. But if that happens after the time for a prayer has ended, there is no sin on them. When this ignorant person who had prayed badly came to know during the time for prayer that it was obligatory to pray at a measured pace, praying at a measured pace became obligatory upon him at that time, but it had not been obligatory for him before that. Hence (the Prophet (blessings and peace of Allah be upon him) instructed him to pray at a measured pace in the prayer that was due at that time, and not those that he had done before it. End quote.
Majmoo‘ al-Fataawa, 22/44
Shaykh Ibn ‘Uthaymeen (may Allah have mercy on him) said:
If a person omits an obligatory duty because he is unaware that it is obligatory, he is not obliged to make it up if the time for it has ended, based on the fact that the Prophet (blessings and peace of Allah be upon him) did not instruct the one who prayed badly – and did not pray at a measured pace – to make up past prayers. Rather he instructed him to offer the prayer that was currently due in the prescribed manner. End quote.
Al-Usool min ‘Ilm al-Usool, p. 32
Based on that, you do not have to make up missed prayers but you have to pray properly in the future.
And Allah knows best.