The question of how an atheist can have morals is a classical example of circular reasoning.
The question has been seriously posed for many centuries, usually without the how, i.e. "Can an atheist have morals?" Indeed, that question often appears in various Theology 101 courses, where it is usually answered with a resounding no.
The problem that leads to circular reasoning is that the question is based on several assumptions, namely:
These assumptions will inevitably lead to one and only one conclusion: An atheist is not motivated by God's will, hence an atheist cannot be moral.
As such, the question is completely useless. It offers no insight into what motivates an atheist in behaving a certain way. It offers no possibility of real dialog between a theist and an atheist.
Curiously, it also implies another assumption, namely that everyone is either a theist or an atheist, while tertium non datur. It sort of reminds me of a scene from an old Russian movie where someone meets a Russian Orthodox priest and asks him incredulously, "You believe in God!?" The priest replies, "Everyone believes in God, some that he exists, others that he does not." Clearly, he has never heard of nontheists.