The names Gog and Magog in the Bible
Magog is often mentioned in conjunction with Gog and Gog is the name of a Reubenite (1 Chronicles 5:4), but later also the name of a certain prince of Rosh, Meshech and Tubal (literally the Chief Prince of the Occupied Zone that is The World — Ezekiel 38).
John the Revelator sees Gog (Γωγ) and Magog (Μαγωγ) — "the nations which are in the four corners of the earth" — gathered up by satan for the final battle (Revelation 20:8). This is remarkable because Daniel sees a vision of a male goat whose one horn becomes four horns towards the four winds of heaven, which may allude to a world-wide altar (Daniel 8:8).
The altar on which continuously incense burned (see Ephesians 5:2) had horns on its four corners (Exodus 38:2) and Daniel also speaks of the defilement of the altar (11:31, 32). The male goat is explained to be Greece (8:21), or Javan in Hebrew. Javan was a son of Japheth, and a brother of Magog, Meshech and Tubal (Genesis 10:2).
Through the prophet Ezekiel, YHWH foretells an attack upon Israel by Gog, "in order that the nations may know Me when I shall be sanctified through you before their eyes, O Gog" (Ezekiel 38:16), but then diverts onto the undoing of Gog and Magog (Ezekiel 39). Gog will fall where he stands (v4) and Magog will perish through fire (v6). The people of Israel will take seven years to burn all the weaponry (v9) and seven months to bury the people of Gog in the valley of Hamon-gog (11-12). And the city (in the valley?) will be called Hamonah (v16).
Etymology and meaning of the names Gog and Magog
The name Magog is the name Gog with a prefixed mem, which may be a particle of inquisition: מה (me), what, or מי (mi), who? Or it may come from the particle מן (min ; often abbreviated to a single mem), meaning from.
Where the name Gog comes from is not clear; BDB Theological Dictionary resolutely declares its root unknown. Jones' Dictionary of Old Testament Proper Names, on the other hand, points towards the Hebrew word גג (gag), usually meaning roof:
Because we've already linked God and Magog to the altar of incense (see above), the most remarkable usage is in Exodus 30:3 and 37:26 where גוג denotes the top of the altar of incense.
Gog may be a region, and Magog is then said to mean From Gog (BDB Theological Dictionary). But Ezekiel 38:2 speaks of a man named Gog who is of the land of Magog (= the land of the land of Gog), which seems overly redundant.
But Gog may mean Roof, and Magog may subsequently mean Off The Roof, which means more in English than in Hebrew. Possibly, the rooftop is semi-synonymous to a place of worship, especially pagan worship, and Magog denotes that same inclination.