Galaxy formation in the universe is still one of the most active research areas in astrophysics. This is also true for galaxy evolution. Some ideas of how galaxies formed, however, are now widely accepted.
After the Big Bang, the universe had a period when it was remarkably homogeneous, as can be observed in the Cosmic microwave background, the fluctuations of which are less than one part in one hundred thousand.
The most accepted view today is that all the structure we observe today was formed as a consequence of the growth of primordial fluctuations. The primordial fluctuations caused gas to be attracted to areas of denser material, and star clusters and stars. One consequence of this model is that the location of galaxies indicates areas of higher density of the early universe. Hence the distribution of galaxies is closely related to the physics of the early universe.
A great deal of the research in this area is focused on components of our own Milky Way, since it is the easiest galaxy to observe. The observations which must be explained in, or at least not at odds with, a theory of galactic evolution, include:
Spiral galaxies in the universe.
The earliest modern theory of the formation of our galaxy (known by astronomers as ELS, after the initials of the authors of that paper, Olin Eggen, Donald Lynden-Bell, and Allan Sandage) describes a single (relatively) rapid monolithic collapse, with the halo forming first, followed by the disk. Another view published in 1978 (known as SZ for its authors, Leonard Searle and Robert Zinn) describes a more gradual process, with smaller units collapsing first, then later merging to form the larger components. An even more recent idea is that significant portions of the stellar halo could be stellar debris from destroyed dwarf galaxies and globular clusters that once orbited the Milky Way. The halo would then be a "new"er component made of "recycled" old parts!
In recent years, a great deal of focus has been put on understanding merger events in the evolution of galaxies. Rapid technological progress in computers have allowed much better simulations of galaxies, and improved observational technologies have provided much more data about distant galaxies undergoing merger events. After the discovery in 1994 that our own Milky Way has a satellite galaxy (the Sagittarius Dwarf Elliptical Galaxy, or SagDEG) which is currently gradually being ripped up and "eaten" by the Milky Way, it is thought these kinds of events may be quite common in the evolution of large galaxies. The Magellanic Clouds are satellite galaxies of the Milky Way that will almost certainly share the same fate as the SagDEG. A merger with a fairly large satellite galaxy could explain why M31 (the Andromeda Galaxy) appears to have a double core.
The SagDEG is orbiting our galaxy at almost a right angle to the disk. It is currently passing through the disk; stars are being stripped off of it with each pass and joining the halo of our galaxy. Eventually, only the core of SagDEG will exist. Although it will have the same mass as a large globular cluster like Omega Centauri and G1, it will appear rather different, as it has far lower surface density due to the presence of substantial amounts of Dark matter, while globular clusters appear, mysteriously, to contain very little dark matter.
Further examples of satellite dwarf galaxies that are in the process of merging with the Milky Way are the Canis Major Dwarf Galaxy, discovered in 2003 and thought to be responsible for the Monoceros Ring, and the Virgo Stellar Stream, discovered in 2005.
Elliptical galaxies in the universe.
Giant Elliptical galaxies are probably formed by mergers on a grander scale. In the Local Group, the Milky Way and M31 (the Andromeda Galaxy) are gravitationally bound, and currently approaching each other at high speed. Since we cannot determine the speed of M31 perpendicular to the line from us to it, we do not know if it will collide with the Milky Way. If the two galaxies do meet they will pass through each other, with gravity distorting both galaxies severely and ejecting some gas, dust and stars into Intergalactic space. They will travel apart, slow down, and then again be drawn towards each other, and again collide. Eventually both galaxies will have merged completely, streams of gas and dust will be flying through the space near the newly formed giant elliptical galaxy. Out of the gas ejected from the merger, new globular clusters and maybe even new dwarf galaxies may form and become the halo of the elliptical. The globulars from both M31 and the Milky Way will also form part of the halo; globulars are so tightly held together that they are largely immune to large scale galactic interactions. On the stellar scale, little will happen. If anybody is around to watch the merger, it will be a slow, but magnificent event, with the sight of a distorted M31 spectacularly spanning the entire sky. M31 is actually already distorted: the edges are warped. This is probably because of interactions with its own galactic companions, as well as possible mergers with dwarf spheroidal galaxies in the recent past - the remnants of which are still visible in the disk populations.
In our epoch, large concentrations of galaxies (clusters and superclusters) are still assembling. This "bottom-up" picture is referred to as hierarchical structure formation (similar to the SZ picture of galaxy formation, on a larger scale).
While we have learned a great deal about ours and other galaxies, the most fundamental questions about formation and evolution remain only tentatively answered.