Foreshadowing is a term thrown aronud 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 sudden 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.
If you think about it, this same thing applies to video games. Which is more satisfying to play: a boss that kills you with an attack you couldn't have anticipated, or a boss that kills you with an attack you've seen other enemies do before and that the game told you how to counter? Foreshadowing in stories is the same thing.
A common scenario is that the hero needs to be rescued. If your hero is trapped and about to be executed and at the last second another character shows up and saves them, that's probably going to upset audiences because you got 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.
Note that no amount of retrospective explanation can fully repair the damage. 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 from the audience's perspective, you cheated to save the hero. The only way to avoid this feeling of disappointment is foreshadowing.
Attack on Titan shows us how. In volume 10 of the manga version, a group of characters are cornered by monsters, but when the main heroes show up and rescue them, it doesn't feel like a cop-out because the end of volume 9 showed the heroes deciding to go to where the others characters needing rescuing for another reason.
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.
I'll go ahead and use an example from my own novel-in-progress, the working title "Rebels". This one shows less obvious foreshadowing. 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 even 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 revolution, they're ambushed and most of them killed, but the rebel family shows up and saves Telra. This feels fair because you knew the rescuers existed and Telra meeting them was how the plot was going to proceed anyway - just not in this way. (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 agrees with 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 the readers excited to see the story go this direction (I wasn't the only one; I know that from experience). 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 and I'm sure you agree if you watched the show.
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 the story this direction is fine, but don't make promises you don't intend to keep.
Now, red herrings are a legitimate thing. It's possible to validly mislead the reader. But to do this you have to give 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?