You missed out the bits before it.
Exodus 20:8 "Remember the Sabbath day, to keep it holy.
9 Six days you shall labor, and do all your work,
10 but the seventh day is a Sabbath to the LORD your God. On it you shall not do any work, you, or your son, or your daughter, your male servant, or your female servant, or your livestock, or the sojourner who is within your gates.
11 For in six days the LORD made heaven and earth, the sea, and all that is in them, and rested the seventh day. Therefore the LORD blessed the Sabbath day and made it holy.
He is quoting Genesis to teach Sabbath observance, not six day creationism.
The thing is, illustrations don't even have to be literal, Jesus taught using parables as illustrations and they are not literal. If we look at the same commandment in Deuteronomy it says,
Deut 5:12 "'Observe the Sabbath day, to keep it holy, as the LORD your God commanded you.
13 Six days you shall labor and do all your work,
14 but the seventh day is a Sabbath to the LORD your God. On it you shall not do any work, you or your son or your daughter or your male servant or your female servant, or your ox or your donkey or any of your livestock, or the sojourner who is within your gates, that your male servant and your female servant may rest as well as you.
15 You shall remember that you were a slave in the land of Egypt, and the LORD your God brought you out from there with a mighty hand and an outstretched arm. Therefore the LORD your God commanded you to keep the Sabbath day.
Here the illustration to teach Sabbath observance is the Exodus, but it isn't a literal description of the Exodus, God's ' mighty hand and an outstretched arm' is a metaphor. Even in the ten commandments metaphors can be used to illustrate the teaching. Here is another: Deut 5:6 I am the LORD your God, who brought you out of the land of Egypt, out of the house of slavery. They weren't all imprisoned in one literal giant house.
The thing is, we need to look at what the message being taught is, not mistake the illustration for the real meaning. Moses was no more teaching literal six day creationism, than he was divine anatomy, or Egyptian architecture.