If we look at this article, it shows a timeline of the Patriarchs
The genealogical list in Genesis can teach us more than just a list of names; it is the story of our historical ancestors.
answersingenesis.org
This article states that the story of Gilgamesh was written about 1600 BC which ironically is shortly after the flood. Pay attention to Shem’s timeline.
But let’s also pay attention to where it is written. Yes, it is written in the same land Abram is called out of.
The epic of Gilgamesh is an amazing story and we learn that a king was oppressing the people. The people cry out and the gods (plural) respond. This gives us a glimmer of the gods of Mesopotamia and how in an odd way, seem concerned with humanity.
A few hundred years later Abram is called out of this land and makes his way westward to what would be later called, “ the promised land”. Ironically, these gods are nothing like the gods where Abram came out of. These gods are mean, cruel and angry. As such, they demand payment to appease them in the form of sacrifice, including children. They are barbaric.
While the story of Gilgamesh parallels much of the flood account, and even has “caring” gods, I get the idea that these epics were distortions of what Moses would eventually accurately write.
And where did Moses hear these stories? Well, Abraham may have heard it from his Father who may have heard the story directly from Noah himself and if tradition is true, then perhaps Abraham heard it directly from Shem and the story was simply preserved until Moses wrote it.