You are thinking as a human thinks, and not as God thinks.
God is outside of time — anything is possible with him.
You're starting from a false premise, the very kind that atheists use to try to catch Christians.
God is outside time, true. But that does not logically lead to the conclusion that He can do anything.
Besides, God cannot do anything. He cannot change, He cannot lie, He cannot deny Himself, He cannot be unfaithful.