Praise be to Allah.
If a person pays zakaah more than the amount that is required of him, thee extra amount is regarded as charity (sadaqah) for which he will be rewarded, because Allah says (interpretation of the meaning): “And whoever does good voluntarily, then verily, Allaah is All-Recogniser, All-Knower” [al-Baqarah 2:158].
It is the same whether this additional amount was given deliberately or by mistake.
But he cannot count this additional amount as zakaah for the coming years, because one of the conditions of giving zakaah in advance is that it should be intended as such at the time of giving it.
Imam al-Shaafa‘i mentioned an issue that is similar to this: a man paid the zakaah on his wealth before the end of the year, then his wealth was destroyed before zakaah became due on it, and he wanted to allocate the wealth he had paid as zakaah on other wealth that he had: is that acceptable?
Imam al-Shaafa‘i said: He does not have the right to do that, because his intention was to pay it as zakaah on specific wealth that he had. So he does not have the right to divert his intention concerning it after paying the money to those who were entitled to it.
End quote from al-Umm, 2/24
Shaykh Muhammad ibn ‘Uthaymeen (may Allah have mercy on him) was asked: I paid twenty thousand riyals as zakaah for the year 1411 AH, then I calculated the zakaah on my wealth for the same year, and I found that it was fifteen thousand. Is it permissible to regard the extra amount as zakaah for the year 1412 AH, even if that is without intention (niyyah)?
This questioner paid more zakaah than was required of him, and he is asking whether he can count it towards the zakaah of the next year.
I say that he cannot count it towards the zakaah of the next year, because he did not intend it as such. Rather it is charity (sadaqah) which will bring him closer to Allah, may He be glorified and exalted, because the Prophet (blessings and peace of Allah be upon him) said: “Actions are but by intentions, and each person will have but that which he intended.”
End quote. Majmoo‘ Fataawa al-Shaykh Ibn ‘Uthaymeen, 18/308
And Allah knows best.