The Quran does not say that the earth is not moving!
It is not permitted to the Sun to catch up the Moon, nor can the Night outstrip the Day: each (just) swims along in (its own) orbit (according to Law). Yasin/40
It is He Who created the Night and the Day, and the sun and the moon: all swim along, each in its rounded course.
The Quran does not say that the earth is flat!
The question refers to a verse from the Qur’an in Surah Nuh:
"And Allah has made the earth for you as a carpet (spread out)." The Holy Qur'an, Chapter 71, Verse 19
But the sentence in the above verse is not complete. It continues in the next verse, explaining the previous verse. It says: "That ye may go about therein, in spacious roads." The Holy Qur'an, Chapter 71, Verse 20
A similar message is repeated in Surah TaHa:
"He Who has made for you the earth like a carpet spread out; has enabled you to go about therein by roads (and channels)...." The Holy Qur'an, Chapter 20, Verse 53
The surface of the earth i.e. earth’s crust is less than 30 miles in thickness and is very thin as compared to the radius of the earth which is about 3750 miles. The deeper layers of the earth are very hot, fluid and hostile to any form of life. The earth’s crust is a solidified shell on which we can live. The Qur’an rightly refers to it like a carpet spread out, so that we can travel along its roads and paths
Not a single verse of the Qur’an says that the earth is flat. The Qur’an only compares the earth’s crust with a carpet. Some people seem to think that carpet can only be put on an absolute flat surface. It is possible to spread a carpet on a large sphere such as the earth. It can easily be demonstrated by taking a huge model of the earth’s globe covering it with a carpet.
Carpet is generally put on a surface, which is not very comfortable to walk on. The Qur’an describes the earth crust as a carpet, without which human beings would not be able to survive because of the hot, fluid and hostile environment beneath it. The Qur’an is thus not only logical, it is mentioning a scientific fact that was discovered by geologists centuries later.