If galaxies are moving away from each other then why are the Milky Way and Andromeda galaxy coming towards each other? The Andromeda Galaxy is approaching the Milky Way at about 684000 mi/hours, making it one of the few blueshifted galaxies. The Andromeda Galaxy and the Milky Way are thus expected to collide in about 3.75 or 4.5 billion years.

Why are some galaxies moving away and why are our galaxy and Andromeda coming towards each other?
The farther away, the faster the galaxies move away from us. But that's only the overall expansion of the universe. Locally velocities can differ and are to be added to the overall expansion. The Andromeda Galaxy is close enough to Milky Way to be able overcome the overall expansion of space. The Andromeda Galaxy and the Milky Way attract each other by gravity.

Hubble's law applied to Andromeda Galaxy/Milky Way returns an expansion of space of less than 70 km/s, since Hubble's constant is about 70 km/s/Mpc, and the distance is about 2.5 million light-years, less than 1 Mpc (= 3.26 light-years, see Parsec). That speed is slower than the about -300 km/s helio-radial velocity (space expansion already subtracted) of the Andromeda galaxy, hence feasible to overcome.