Sonic XG is a fan project, and the reliable route is the Sonic Retro community, which archives this kind of release along with a great deal of other Sonic history.
The general process: find the project's page, open the entry for Sonic XG, and follow the download link it provides. Once the archive is on your machine, extract it with an archiving tool such as WinRAR or 7-Zip, then run the executable inside.
Two expectations to set. Fan games of this vintage are frequently unfinished, so bugs and abrupt endings are normal rather than a sign you downloaded the wrong file. And download only from the community that hosts the project — search-result mirrors for old fan games are a standard distribution point for bundled adware.