Hubble's law states that the universe is expanding with a velocity equals Hubble's constant*distance from earth. But, recent findings show that the Andromeda galaxy is actually blueshifting towards us and nearby stars and galaxies do show motion with respect to the Earth with so called peculiar velocities. What's the catch here? I am a beginner in this subject matter. Any help would be duly appreciated.
Hubble's law applies to the expansion of space itself, i.e., if two objects stationary to each other that had no force between them were left alone the distance between would increase with time because space itself is expanding. This is what Hubble's law addresses.
In the case of the Milky Way and Andromeda galaxies (and all galaxies for that matter) there is a force between them: gravity. The gravitational force between the Milky Way and Andromeda galaxies has produced an acceleration that is causing the two galaxies to be moving towards each other faster than the space between them is expanding as calculated by Hubble's law. However, the vast majority of galaxies lie far enough away from the Milky Way that the gravitational force between us and them is small compared to the Hubble expansion and Hubble's law dominates.
In short, Hubble's law applies throughout the universe, but localized systems may have enough gravitational attraction between them that the gravitational effects dominate.
Hubble's law applies to galaxies that are locally at rest in their regions of the Universe. Any galaxy that is locally in motion will either add or subtract something to/from its redshift due to this motion. This is seen as a scatter around the linear relation in e.g. this plot of the Hubble law:
Looking at the plot, one can see that e.g. in the Virgo cluster, there is a quite large spread around the line - this is because they are strongly gravitationally bound and have high peculiar velocoties. In fact, we can see that some of the Virgo galaxies have much higher peculiar velocoties towards us than Andromeda has, but Virgo is so far away from us that its region of space in general is receding from us.
Andromeda, on the other hand, has a relatively low peculiar velocity, but it is so close to us that the Cosmological expansion in Hubble's law is almost completely insignificant. Therefore, it is blueshifted.