The arrival of Mahdi has 2 different stories in Islam: Sunni Islam, and Shia Islam.
According to sunni Islam, Ali bin abi Talib narrates: the prophet peace be upon him narrates
المهدي منا أهل البيت، يصلحه الله في ليلة
roughly translates (my translation) into
Mahdi is from our descendants (Ahlu l Bayt), Allah guides him during a night
Scholars interpreted guides
in 2 ways:
- Allah prepares him to lead the Ummah as the Mahdi (mentally and psychologically etc...) after he'd been a very pious and religious muslim since forever, or
- Allah guides him to his straight path, and guides him to be very pious after he'd been just like any other person (prone to sins), then guides him to become the Mahdi
In either cases, many people matchmatched the identification marks from the hadiths in history, even some con-artistsof them claimed to be the Mahdi themselves multiple times (and been punished for it), but still, as the hadith above suggests, the Mahdi will not know he's THE MAHDI until the time comes.
Notice how Allah guides him during a (single) night
, not a few nights or weeks. It happens overnight.
PS: I don't know anything about the Shia story of Mahdi, as such I did not mention it in the answer.