You have been lied to, he was not an atheist, he was just a free thinker, who saved the Turkish nation and many millions of Muslims from the balkans, the Russian empire Greece Bulgaria etc.
And the Khilafate was destined to collapse anyway, the birth of the modern nation state did not allow for archaic institutions of the middle ages.
Also what Khilafete, from which sect from which country, who would decide, who would get such a position.
Ataturk not only saved Turkey but set down foundations for the modern powerful state that Erdoğan benefits from.