In Pokémon Sapphire or Ruby, go to Slateport and find Captain Stern. After Team Aqua steals the submarine, return to the Aqua Hideout, where you can enter. You can also find a Master Ball there, which is useful for catching Latios or Latias.
In Pokémon Emerald, first go to Mount Pyre and defeat the Aqua leader. Enter and exit through the other door on the first floor without going up or down, then proceed with the remaining steps.