Good question. The reason that galaxies themselves don't pull themselves apart is the same reason that planets are not pulling themselves apart -- gravity. Galaxies are big. Really big. They also contain a lot of mass; therefore, they have a lot of gravity. But they are still moving apart because they are not close enough to each other for their gravity to pull them toward each other. Newton's Law of Universal Gravitation states that gravity depends on the mass of two objects and the distance between them. Greater distance means less gravity. Galaxies are really far apart from each other, so despite their mass, there isn't much gravitational attraction there. At least there isn't enough to overcome whatever force pushed them apart (or is still pushing them apart).
A single galaxy on the other hand is tightly packed together compared to the vast distances that exist between galaxies. Additionally, the density of material increases as you move toward the center of a galaxy. Whether the center of every galaxy is just a bunch of stars or a black hole of some kind, the center is most definitely really massive. That mass, together with the relative proximity of the rest of the matter in the galaxy, holds the galaxy together; therefore, galaxies don't expand.