Ezekiel 38 and Ezekiel 39 describe the Battle of Gog and Magog that happens before the Millennium, whilst Revelation 20 describes the Battle of Gog and Magog that happens after the Millennium.
Ezekiel 38 and Ezekiel 39 speak of the President (Gog) of Russia (Magog) who brings the kings of the East against Israel (Revelation 16: 12) for the Battle of Armageddon and is subsequently destroyed by God’s divine intervention.
Revelation 20: 7 - 10: And when the thousand years are expired, Satan shall be loosed out of his prison, And shall go out to deceive the nations which are in the four quarters of the earth, Gog and Magog, to gather them together to battle: the number of whom is as the sand of the sea. And they went up on the breadth of the earth, and compassed the camp of the saints about, and the beloved city: and fire came down from God out of heaven, and devoured them. And the devil that deceived them was cast into the lake of fire and brimstone, where the beast and the false prophet are, and shall be tormented day and night for ever and ever.
Satan will be loosed from prison after the Millennium and will for an undefined space of time (Revelation 20: 3) go forth and deceive those peoples who lived during the Millennium whose hearts were not genuinely changed to sincerely serve the LORD.
Satan is Gog in Revelation 20, and the deceived nations are Magog who will come and make war against Christ and His Bride, just as Satan caused Russia and the kings of the East to come against Israel in Ezekiel 38 and Ezekiel 39.