It's because Glitch City has a profound effect on Pikachu's over world Al.
AI stands for Artificial Intelligence, it is used to simulate human-like intelligence, intelligent behaviours or subsets of intelligent behaviours primarily in non-player characters (NPCs). I don't why Glitch City has an effect on Pikachu's over world AI but it does.
In Pokémon Yellow, Glitch City has a profound effect on Pikachu's overworld AI, causing it to run to and from random places. Walking onto certain glitched tiles also makes it disappear, though after the player leaves such tiles, Pikachu will reappear and follow the player's recorded path. Pikachu's friendship will reset in Glitch City, causing it to dislike the player.