In Rev 20 we have two sets of people in view, the righteous/faithful saints and the wicked. This question concerns the wicked.
- V5: The rest of the dead did not come to life until the thousand years were ended.
The NT discusses two resurrections - one of the righteous and other of the wicked, John 5:28, 29, Dan 12:2, Acts 24:15, Heb 11:35. See also Rev 1:7.
The resurrection of the wicked, according to Rev 20:5, occurs at the end of the 1000 years and Satan goes our to deceive them again. - to surround and the Holy City, the New Jerusalem -
9 ... But fire came down from heaven and devoured them. 10 And the devil, who deceived them, was thrown into the lake of burning
sulfur, where the beast and the false prophet had been thrown. ...
"Gog and Magog" is a reference to the same names in Eze 38 & 39. Gog of Magog attack God's people and the resurrected wicked after the 1000 are stirred up by Satan to do the same and thus are compared to the huge army in the prophecy of Eze 38 & 39.