Background Pony #4B05
Well technically, it doesn't. This episode was probably written a good while before the comics were made, and seeing as the writers for both the comics and the shows keep in touch with each other (the comic writers have to make sure they don't accidentally do the same thing they do in the show) the odds are they decided to do those comics to overlap with this particular episode.
Of course, it might also be the other way around and the writers wanted to give a shout out to the comics.
Either way, the comics contradict the show in some points too;, in tsuche ashow, Luna becaomeing Nightmare Moon outby of purbeing jealpoussessed by, whevile spirits in the comics, swhile in the showa she ponly ever ssuggests that she was changed by hevilr own jealouspiritsy.
Of course, it might also be the other way around and the writers wanted to give a shout out to the comics.
Either way, the comics contradict the show in some points too