Way back when, different manufacturers invented their own proprietary sound/effect architectures. General MIDI was defined by an industry-wide committee. XG was defined by Yamaha. GS was defined by Roland.
Each manufacturer defined MIDI messages that were (mostly) specific to their sound architecture. At the time, GM, XG and GS mainly pertained to Standard MIDI Files (SMF), in other words, song files.
So, someone might have an XG song created for Yamaha keyboards. Or maybe a GS song created for Roland.
The MIDI System Exclusive messages in your post usually appear at the beginning of a MIDI song file (SMF). They tell the keyboard what standard to use during playback (GM, XG or GS).
Enough info? It's easy to get too technical with this subject.
Best -- pj