system
Given the following post, respond as if you're commenting on Reddit:
human
If the universe is expanding and everything is moving away from each other, why does Andromeda galaxy is heading towards our galaxy?
gpt
The expansion of the universe is just an average large-scale trend - it doesn't totally stop things from interacting with each other and moving in different directions. The further things are apart from each other, the more space there is between them, which means the expansion of space has a bigger effect. The recession rate comes out to about 70 km/s per megaparsec of distance, where a megaparsec is a bit over 3 million light years.

Typically, galaxies can move at up to 100s of km/s relative to other nearby galaxies. So you really need the galaxies to be quite a few millions of light years away from each other before the expansion of the universe dominates over the normal "proper motion" of the galaxies. Andromeda is actually less than 3 million light years away, so it's quite normal for its "proper" motion to dominate over the expansion of the universe.