In multiple episodes the incredible distance between The Milky Way and Andromeda is dealt with fairly accurately or at least consistently: even at highest warp the 2 million light years that separate the two galaxies mean that it would take many lifetimes to reach it. (This is in "By Any Other Name" -- even with Kelvan modifications, the ship will still take centuries to reach Andromeda.)
I am not sure about Lost in Space or Outer Limits in this respect -- but both of these shows tended to play loose with speed and distances.
Later shows, like Stargate, nod to intergalactic distances but allow such travel using wormholes or indeed Stargate's.
Was Star Trek the first TV series or even movie that dealt with the great distances between galaxies?