There are three ways to foreshadow in RPGs:
(1) Strew the foreshadowing around liberally. If the PCs might go to location A or they might go to location B, foreshadow both of them: Whichever one they go to has now been foreshadowed and they’ll think you’re brilliant. The foreshadowing for the other will simply be irrelevant trivia or, at worst, red herrings.
(2) Retroactive foreshadowing. After a few sessions, look at what the PCs have actually done / experienced. Now, take some of that stuff (particularly stuff they liked) and use it as the building blocks for prepping the next chunk of the campaign. (For example, maybe they were fascinated by the small jade statue of a knight that you included as a piece of random treasure. Make the next major villain in the campaign a knight who wears green armor.)
(3) Vague foreshadowing. Simply make statements that would be true or significant regardless of the specifics of a given event. (For example, when Gandalf says, “My heart tells me that Gollum has some part to play yet, for good or ill, before the end; and when that comes, the pity of Bilbo may rule the fate of many – yours not least.” Tolkien is very specifically foreshadowing the role he knows Gollum will play in saving Frodo’s life and completing the quest to destroy the ring. But even if Tolkien were just a GM who had no idea where the story was going at that point, he could just as easily have Gandalf say that. The statement, after all, boils down to nothing more than saying, “Gollum is going to do something and this quest is pretty important.” Which is pretty much a given since, at that point in the story, Gollum is already following them.)
If it’s all just a trick, why do it? Well, foreshadowing can be used to give a sense of cohesion and completeness to the campaign. It can also invest the players with a feeling that what their characters are doing is important. It can also be used to reinforce themes. Basically, you can use foreshadowing in a roleplaying game to achieve all (or most) of the things that it can be used for in other mediums; the only difference is that the non-linear nature of a good RPG scenario forces a different execution of the foreshadowing.