In Firered and leafgreen Gary is your rival and later the champion. In heartgold soulsilver there is a character called Blue. I'm convinced they're the same but why were the names changed
Their names weren't changed. The Gary counterpart in FRLG is still called Blue, as is the main character is called Red.
In Pokémon Red, Green, and Blue, Pokémon Yellow, and Pokémon FireRed and LeafGreen, Blue is the player's rival: he will meet up with the player as he or she journeys across the Kanto region, challenging him or her every once in a while to test their skills. Like the player, he receives a starter Pokémon from Professor Oak, his grandfather: the one he chooses will be of the type which weakens the type of the player's choice. In Yellow, he will take the Eevee Oak had intended for the player.
They did this because Gary's "Anime Counterpart" is named Blue.
Hope I helped and that this is what you were asking!