Fugues are generally unmistakable because they all begin in the same way, which is A.) The theme is played by itself starting on a given pitch, then B)The theme is played all over again, except at a different pitch. While it's played at that different pitch the first "voice" continues to play in a way that harmonizes with the second voice. Then C.) the theme is taken up by yet a third "voice" at yet a third pitch, while the first two voices continue to harmonize with it. Some fugues go on to add a fourth "voice."
From there, things develop in complicated ways, but throughout you keep hearing the theme re-entering at different pitches while the other voices harmonize with it.
Here is a kind of joke fugue written by Glenn Gould for 4 voices (It's a real fugue, but he intended the lyrics to be funny). It's actually sung, and has lyrics, which is why I point it out: it's easy to identify the different voices that way.
Now here's Bach's g minor fugue on piano. Listen with an ear to catching the theme repeated at different pitches by all the different voices.
If you listen to enough fugues you easily get to the point where you know it's a fugue as soon as the second voice enters, even if you haven't heard it before.
As for inventions, the first three two-part inventions by Bach seem sort of like fugues at first, but they are different than fugues because the second "voice" repeats the theme at the octave, which never happens in a fugue. None of the other inventions have that form. The reason they're called "inventions" is because the composer invents the form rather than using some pre-existing form.
The Goldberg variations are variations. It's hard to tell because they're unusual variations. He is varying some element of the base line instead of varying the theme, which usually makes variations instantly recognizable. The Goldberg's aren't good variations to use to learn what variations are.
Here's a much more accessible example of variations: