We cannot know for sure why there are so many flood stories in the cultural histories of peoples from such far apart places in the world. Social sciences have advanced various hypotheses on this issue. The two most important have to do with ancient events and with the attempts of ancient people to explain various phenomena that they observed.
One way to look at flood myths is to say that they were rooted in reality. Of course, Christians who take the Bible literally say that it was Noah’s flood that inspired all of these legends. However, since there is no broadly accepted scientific proof that Noah’s flood ever happened, most social scientists point to smaller-scale events. They argue that there were many times in prehistory when large floods occurred. These would be floods like the glacial Lake Missoula floods in the American Northwest. These floods, while not global, could have given rise to such legends.
Another way to look at these myths is to say that they were created to account for various phenomena that people observed. For example, there are many places where there are fossilized remains of sea life far above sea level. Ancient peoples might well have come up with flood legends as a way to explain these remains.
Of course, we will never know the answer to this since the people who made up the myths are not around to tell us what inspired them.