Is it true that the Andromeda Galaxy is blueshifted and moving toward us? How can this happen in an expanding universe?
The Andromeda Galaxy (M31) is indeed approaching us, by about 300 kilometers (190 miles) per second measured with respect to the Sun. If you subtract the Sun’s orbital motion around our galaxy (about 230 km per second toward Cygnus), M31 is still approaching the Milky Way by about 130 km per second. The two galaxies will merge a few billion years from now.
This is normal. Neighboring galaxies are bound into clusters by their mutual gravitational attraction. Individual galaxies drift about at random with their own “peculiar velocities,” typically a few hundred kilometers per second with respect to the cluster’s average. The overall expansion of the universe doesn’t dominate until you venture beyond a few tens of millions of light-years. Even then, there are large-scale flows due to the gravitation of the Virgo Supercluster and more distant structures such as the Great Attractor in Centaurus. M31 isn’t alone; about 100 galaxies show blueshifts rather than redshifts. Most of these are dim dwarfs in and near our Local Group, which is dominated by the Milky Way and M31.
— Alan MacRobert