Praise be to Allah, and peace and blessings be upon the Messenger of Allah. To proceed:
The fact that some of the characteristics mentioned in the hadiths apply to a person does not necessarily mean that he knows he is the Mahdi or believes that he is. He may be a righteous and pious person who has no desire for authority or aspirations for positions of leadership, and therefore dislikes being attributed such a great status to himself.
Moreover, merely having the same name or matching physical characteristics does not establish that someone is the Mahdi. Some people have falsely claimed to be the Mahdi because they were deceived by such matters, resulting in great turmoil and tribulations.
It is also not necessary that the Mahdi himself has read or memorized the hadiths concerning him, as these reports are not among the foundations of faith or the pillars of religious practice.
His initial refusal to accept the pledge of allegiance may also be out of piety and fear of the responsibility that comes with authority. The Prophet ﷺ said to Abd al-Rahman ibn Samurah رضي الله عنه:
“Do not ask for leadership, for if you are given it because you asked for it, you will be left to it, but if you are given it without asking for it, you will be helped in carrying it.”
Narrated by Al-Bukhari and Muslim.
We do not know of any authentic, explicit text indicating that the Mahdi will recognize himself through these signs, or that he will use the swallowing of the army by the earth as evidence that he is the Mahdi.
What is established is what the Prophet ﷺ informed us about the Mahdi and what will occur during his time. As for the details of how he will recognize himself and why he initially refuses the pledge of allegiance, there is no explicit text concerning them. What has been mentioned regarding these matters is only among the possible explanations.
And Allah تعالى knows best.