The expansion of the universe, as described by the theory of cosmic expansion, states that on large scales, galaxies are moving away from each other due to the overall expansion of space. This expansion is happening on the largest cosmic scales and is caused by the properties of dark energy.
If it takes us 3 million years to travel to the Andromeda Galaxy, which is located about 2.537 million light-years away from us, it's important to understand that the expansion of the universe is happening on a much larger scale than the local motion of galaxies within a galaxy cluster like our Local Group, which includes the Milky Way and Andromeda.
While the Andromeda Galaxy is moving away from us due to the expansion of the universe, the local gravitational interactions within the Local Group dominate the motion of galaxies within it. The gravitational attraction between the Milky Way and Andromeda is causing them to approach each other, and it is predicted that they will eventually collide and merge in about 4 billion years.
Therefore, even if it takes us 3 million years to reach Andromeda, the galaxy itself would still be in a similar position within the Local Group due to the dominant gravitational forces between galaxies. However, the larger-scale expansion of the universe would continue, causing galaxies outside our Local Group to move away from us at an accelerated rate.
It's important to note that our current understanding of the universe's expansion is based on current observations and models. In the distant future, the expansion rate of the universe and the fate of galaxies may be influenced by other factors that are not yet fully understood.