Cosmological effects only occur at cosmological distances. Andromeda is so close to the Milky Way that it feels the gravitational field of the Milky Way as being a stronger factor in its dynamics that the much weaker gravitational field of the rest of the universe. This is a common misunderstanding about Big Bang theory. It says that space expands only at scales where the matter in a particular region of space has about the same average density as the universe. This is not the case inside clusters of galaxies, but becomes closer to the situation at scales many times the size of a cluster of galaxies.