The Bible speaks of the Watchers laying with daughters of men and creating a corrupt race of half spirit/half flesh beings who were giants. The Lenni Lenape told of fighting off a tribe of giants and driving them from the land, down the Mississippi, never to be seen again. The Paiutes tribe had a legend passed down from ancestors of their people fighting a tribe of angry, cannibalistic, red-haired giants, driving them into a cave and burning them. It sounded like a legend to tell of their power and ability to fend off enemies and outsmart them, but in the 20th century, guano farmers found a cave referred to as Lovelock Cave in Nevada, where they dug up a ton of bat guano, but also the relics of these ancient giants with red hair, big skulls, and long bones.
There was a kernel of truth in the legends based on man fighting giants. The part of the legend that is up for grabs is whether or not these was a tribe of cannibalistic fiends that needed to be killed or not. Yet, the actual existence of the giants in that area is verified by the finds. So, legends can be based on an element that actually occurred, but the storytelling of it depends on the interpretation of the people and how it is passed down through generations, translated, and applied to literature.
So, it would appear that giants were incorporated into many legends - a universal element ancestors encountered, but their origins and what happened to them - that is the part where legends are born.
A flood that occurred naturally, explained by a legend, becomes a purposeful killing off of an evil race and a new beginning. These aren't so much literal accounts of actual motivations and magic, but of events. There was a flood. There were giants. If you don't have information as to why and how, you tend to fill in the blanks. We seek answers and often our elders are the ones we refer to, whether it's a shaman, religious leader, professor, or even parent. How many parents have tried to explain why the sky is blue to their child only to realize they don't have a grasp on it and are elaborating?
Gaps in knowledge are space for fictional aspects of something that is very real in basis. Ask a child why the apple falls to the earth and doesn't float. Gaps in knowledge have the child saying, "it's going where the horses will be able to eat them." It doesn't mean an apple didn't fall, it simply means the child doesn't understand gravity and how it works. To the child, the apple had knowledge, that gave intent, that turned to action.
Even today, we fill in our gaps in knowledge with legend. Ghost investigators experience phenomena and they grasp at what they have been told; that ghosts can be trapped and not know they are dead, or have unfinished business, but these are just legends to help us understand something that is a mystery, just the same as man feared retribution from the gods with bad crops or eclipses.
As researchers you must always sort out "legend" from the "kernel."
How do we do this?
First, determine that there is a kernel in this legend. In the case of ghosts, having experienced phenomena myself, I can tell you - it exists!!! But, the explanation of that phenomena, I can find no real correlation that proves any of these "legend" aspects of what a ghost is, how it works, if it is the soul of the dead or projection of the living, a function of the brain, interdimensional, time shifts.... Those are the legends to explain the phenomena.
It gets even hairier; depending on your core belief system, your legends are adjusted. You take the evidence - phenomena, and bend it to suit your belief system. In the case of folks who believe in one body/one soul and it can go anywhere in an afterlife, the phenomena clearly proves that we have life after death and we can be mired to a spot or a person if we have unfinished business.
I say it repeatedly, but "you should not bend the evidence to support your belief. Your belief should be the result of evidence that impresses an obvious conclusion."
The next step in finding out the real whys, hows and whens is to approach the kernel of truth from every angle, not accepting any legend, but asking it to tell you where it came from by the most simple and logical means, by experimentation, interaction, closer analysis, trial and error....