Genesis and Exodus were written after the Babylonian exile.. Until then the Hebrews didn't have any history or foundational myths.. They learned the flood story in Babylon.
I think the Jews already knew of the Babylonian creation and flood myths before 6th century Neo-Babylonian empire.
They probably heard the myths, 1st from their contact with the Neo-Assyrian empire in the 7th century BCE, before Judah finally succumbed to the Neo-Babylonian forces in the early 6th century BCE.
Remember, Judah was a subject or vassal state when Assyria’s empire stretched all the way west to Egypt and poached on the border of the Phrygian kingdom, around 670 BCE. And Israel had fallen.
Even though Judah managed a semi-independence status, they did trade with the powerful neighbor.
Around this time, Ashurbanipal was in power, and unlike his ancestors, Ashurbanipal was interested in arts and literature, and was responsible for the library built at Nineveh, which among the works was the Epic of Gilgamesh.
By the time King Josiah came to power, Assyria was already weakening internally, especially by 627 BCE with Ashurbanipal’s death. This eventually led to Nineveh’s fall in 612 BCE.
Josiah started the foundation myth, to promote Judah’s greatness, most likely the person who started the creation-flood myth, that didn’t complete until the end of the Babylonian Exile.
The Assyrians kept the Bronze Age Babylonian myths alive after the fall of the 2nd dynasty of Babylon.