Galaxies come in different shapes and sizes. What factors determine the shape and size of a galaxy, and how can these change over time?
The size of a galaxy is dependent on how the matter was distributed in the early universe, and how it collapsed under its own gravity to form clumps of (dark) matter that the galaxies would form around.
The very earliest galaxies are irregular, but as matter fell towards them, and they developed a consistent orbital direction they formed into a disc. Gravity waves in the disc then show up as spiral arms. Large galaxies that are actively forming stars tend to have this structure. Small galaxies may never reach the point of forming a disc and remain irregular.
As galaxies collide and interact, the orbits of the stars are disrupted. The result of the merger of two large spiral galaxies is often a galaxy in which the stars orbit in all directions, which looks like an elliptical galaxy. Star formation in elliptical galaxies is often very low. Elliptical galaxies are the most evolved form of galaxies.
The time scale of this evolution is slow. It takes billions of years for galaxies to evolve from one form to another.
The details of the process of galaxy formation and evolution are still uncertain. The exact nature of dark matter will be important in understanding how galaxies form. The role (if any) that black holes play in galaxy formation is uncertain.
Galaxies grow through smooth accretion of matter (both dark and baryonic), and through mergers with other galaxies. Minor mergers (i.e. where one galaxy is much larger than the other) simply disrupt the smaller one without changing the shape of the larger (but may increase its star formation rate for a while). Major mergers, where galaxies are of comparable size, can completely "wreck" the galaxies. If the merging galaxies are spirals, they can sometimes settle down into a larger spiral galaxy, possibly with an enhanced central bulge. But sometimes, depending among other things on their orientation prior to merging, they become ellipticals instead.
Since the Universe is expanding, galaxies were closer together in the past, and thus most of the growth has already taken place.
Small galaxies which undergo intense star formation, may blow out their gas due to stellar feedback, in this way getting rid of most of their gas and thus decrease a little in size and "extinguish" themselves.
Galaxies have their origin from the clumps in the almost smooth primordial soup of gas and dark matter (and radiation). These clumps have a size distribution — the halo mass function — which is a power law at small masses and with a exponential cut-off at large masses. Thus, the size of galaxies follow a similar distribution.
The figure on the left below (created with this tool) shows the distribution of dark matter halos, i.e. number per volume at a given mass today (redshift $z=0$, solid line) and when the Universe was only two billion years old ($z=3$, dashed line). You can see that in early times, the large halos hadn't formed yet.
The figure on the right (from my own cosmological simulation) shows how many stars there are in a (simulated) dark matter halo of a given mass. You can see that it follows an approximate power law, but with quite some scatter.