Foreshadowing is a term thrown around by a lot of storytelling critics and advice-givers on the internet. I can't speak for other people, so I'll say what I mean by it: "The practice of placing hints in a story prior to a twist (defined as "a reveal that significantly changes the reader's perception of the canon") such that the twist can draw on these hints to feel like it was there all along instead of coming out of nowhere". Foreshadowing gives the plot a feeling of consistency and fairness.
A very similar thing applies to video games. I'm not yet certain I understand the significance of the connection, but it is definitely there.
A common scenario is that the hero needs to be rescued. If the hero is trapped and about to be executed and at the last second another character shows up and saves them, that's unsatisfying because you get the hero out of trouble by changing the rules instead of by playing fair. Even worse than just ruining the moment, this destroys the future of the story because the audience can't trust you anymore. They're going to expect you to do this again next time, and so they'll never take the danger as seriously as they did before.
And no amount of retrospective explanation can fully repair the damage after that. Even if the character explains how they knew the hero was in the danger and happened to be around, that won't fix the fact that the solution was something the audience didn't know about, and that will mar every subsequent scene that's supposed to be dramatic. The only way to avoid this feeling of disappointment is foreshadowing.
Attack on Titan shows a good example of doing this right. In volume 9, the main heroes start traveling to a certain location, and in volume 10, a group of other characters get cornered by monsters there, so when the main heroes show up and rescue them, it's not a cheat because the solution was set up in advance.
Another way this can be okay is if it's sufficiently early in the story (I'd say first two chapters in most cases), since then the reader hasn't had time to get used to the rules of the story yet. The opening is meant for setup, not playing by existing rules.
I'll go ahead and use an example from my own novel-in-progress, which I think foreshadows the rescue appropriately. In The Pygon Hybrid, Telra hears from her instructor of a news story about a soldier couple who went rogue, killing several other police and disappearing along with their children. The news report names all four family members to clearly signal that they're going to become characters. When Telra and her mates steal weapons from the government planning to join up with these people and see about starting a rebellion, they're ambushed and most of them killed, but the rebel family shows up and saves Telra. This should feel fair because the rescuers were set up as the future of the plot before the danger started. (And they do explain how they knew to be there.)
On the flipside, proper foreshadowing also involves delivering on everything you've foreshadowed. If you've foreshadowed something you must deliver. I'll give an example of failure.
Also Attack on Titan. I don't remember what episode of the anime or volume of the manga this was, but after the first half of the battle for Trost, general Pixis has a long talk with Eren (the protagonist) about the Titans and human nature, wherein he very strongly implies that the Titans were created to give humanity a common enemy to unify them and that he supports this action. Afterward, Eren says to his friends that "The general understands the situation too well. The titans are not our only enemy." This is very clear foreshadowing that Pixis is involved with the creation of the Titans. It gets us excited to see the story go this direction. But apparently he isn't; ten volumes later in the manga, Pixis has been pretty conclusively shown to be a goodguy and no one ever mentions that scene again. It was incredibly unsatisfying.
The thing I wanted you to take away from that example is that there wouldn't have been a problem if the author hadn't foreshadowed something he didn't plan on doing. No one expected the story to go that way before this scene. Not taking things this direction is fine, but don't make promises you don't intend to keep.
A valid red herring requires giving an alternate explanation for the false clue when the truth is revealed, so that you show the reader you're not wasting or forgetting what you told them. What's not possible to do validly is to give the reader overwhelming evidence that something is the case, have the characters note the evidence, and then ignore it - not show another explanation for Pixis's weird remarks, not even have the characters discuss it and decide they were wrong, just forget the foreshadowing ever happened. That won't upset any fans, right?