Hubble's law says that the universe is expanding.How come the milky way and the andromeda are on a collision course?How will they end up colliding with each other?
The large-scale structure of the Universe is expanding. However, gravity still works, and it's especially powerful if the distance is small. E.g., the Earth is still pulling your body closer to it, even though the Universe is expanding. The Earth and the Moon still attract each other, even though the Universe is expanding. Our whole galaxy is still held together by gravity, even though... You get it.
M31 (a.k.a. the Andromeda Galaxy) is "only" 2.5 million light years away, which is pretty close, by cosmic standards. At that scale, for large objects such as galaxies, gravity overrides cosmic expansion. There is a net positive attraction between us and M31. Our galaxies are being pulled together by gravity.
As to what exactly will happen when they collide, take a look at this simulation:
Or just download the software yourself, it's free:
Only galaxies which are very far away from each other are being pulled apart by the cosmic expansion faster than gravity could pull them together.