There is no sound hadith that says how old the Mahdi will be when he appears
Question

Is there a hadith which says that the Mahdi will be 52 years old when he appears?
Praise be to Allah.There is no proven hadith which indicates that the Mahdi will be 52 years old when he appears; in fact, there is no proven report which says how old the Mahdi will be when he appears.
With regard to the hadith in which it says that the Mahdi will be sent when he is forty years old, it is da‘eef (weak) and cannot be taken as evidence.
That is the hadith which was narrated by at-Tabaraani in al-Mu‘jam al-Kabeer (8/101) and in Musnad ash-Shaamiyyeen (2/410) from Sulaymaan ibn Habeeb, who said: I heard Abu Umaamah say: The Messenger of Allah (blessings and peace of Allah be upon him) said: “Between you and the Byzantines there will be four truces, the fourth of which will be concluded by a man from the family of Heraclius, which will last for seven years. A man from the tribe of ‘Abd al-Qays whose name was al-Mustawrid ibn Kheelaan said to him: O Messenger of Allah, who will be the leader of the people at that time? He said: “A forty-year-old man with a face like a shining star, on whose right cheek will be a black mole, and he will be wearing two white velvet ‘abayahs, as if he is one of the Children of Israel. He will rule for twenty years and bring forth treasures, and will conquer the cities of the mushrikeen.”
This is a da‘eef (weak) hadith that cannot be quoted as evidence. Its isnaad includes ‘Anbasah ibn Abi Sagheerah, who is majhool (unknown).
Ibn Katheer said in Jaami‘ al-Masaaneed wa’s-Sunan (8/528):
This hadith was attributed to ‘Anbasah ibn Abi Sagheerah, but his character and description are unknown. End quote.
Al-Haythami said in Majma‘ az-Zawaa’id (7/319):
It was narrated by at-Tabaraani, and its isnaad includes ‘Anbasah ibn Abi Sagheerah, who is da‘eef (weak). End quote.
In al-Fitan by Na‘eem ibn Hammaad (1/365), it was narrated from Qataadah that ‘Abdullah ibn al-Haarith (may Allah be pleased with him) said: The Mahdi will appearwhen he is forty years old, looking like a man from among the Children of Israel.
This is a report which is not sound, because it was narrated by al-Waleed ibn Muslim, who narrated many reports that he did not hear directly from his shaykh without mentioning the name of the third party from whom he heard it, or he attributed the report to the shaykh from whom he heard it, but referred to the shaykh by a name or description that is not widely known [tadlees]. He narrated this report by saying ‘an [from], narrating it from Sa‘eed ibn ‘Abd al-‘Azeez from Qataadah.
In as-Sunan al-Waaridah fi’l-Fitan by ad-Daani (5/1074), it says: From Qataadah, who said: It was said that the Mahdi will be forty years old, and he will do the deeds of the Children of Israel. If it is not ‘Umar, then I do not know who it will be.
Its isnaad includes Abu Hilaal ar-Raasibi al-Basri, who is da‘eef (weak).
Ahmad ibn Hanbal said: His hadith is problematic.
Al-Bazzaar said: He had a poor memory.
An-Nasaa’i said: He is not qawiy (strong).
See: Tahdheeb at-Tahdheeb (9/196).
Conclusion: there is no sound hadith or report which states how old the Mahdi will be when he appears.
And Allah knows best.