Why do galaxies collide if the universe is expanding?
Galaxies tend for form gravitationally bound groups.
Although the universe is expanding this only means that larger structures are getting further apart.
Galaxies tend to form into groups which are gravitationally bound. Galaxies can also form into larger structures such as clusters and super-clusters.
Galaxies can collide within groups. Our Milky Way galaxy is in a group called the local group. Another member of the group is the Andromeda galaxy. The Milky Way and Andromeda are on a collision course and will collide in about 4 billion years time.