> Is there a theory that predicts galaxies with dark matter, or states how they come to be that way?

Yes, the concordance cosmology (because it concords with all the available evidence), also called the standard cosmology, has an evidence-matching theory of structure formation. The European Space Agency has a good overview at http://www.esa.int/Our_Activities/Space_Science/Planck/Histo...

The evidence for the concordance cosmology comes from terrestrial laboratory physics, tests of general relativity and the standard model at various other places in our solar system, and astrophysical observation. It continues to deliver good predictions (notably about small-scale fluctuations in the cosmic microwave background) but strictly speaking it is an effective theory (it is not complete for the extremely early universe, and it is coarse-grained at length scales larger than galaxies) and it is frequently updated as new information arises, so it's not so much falsifiable (barring falsification of General Relativity, statistical mechanics, thermodynamics, or quantum mechanics, which underpin the cosmology and give it self-consistency) as requiring completion. [ one starting point: https://en.wikipedia.org/wiki/Lambda-CDM_model ]

"CDM" stands for cold dark matter, and its name represents the key features for the (cosmological scale) fluid implied by the behaviour of visible matter: it is [a] moving slowly compared to the speed of light (cold, rather than hot) [b] oblivious to electromagnetism, having and feeling no charge and not decaying to visible matter, and [c] some form of matter rather than an adaptation of General Relativity that amounts to an alternative theory of gravitation.

[a] and [b] also imply that CDM is essentially collisionless, meaning that it (at least mostly) interacts only gravitationally with other matter and itself, which means that it cannot ditch angular momentum that would let it fall into a structure like a galaxy or star (note that normal visible matter -- mostly protons by mass -- can collide, releasing photons and other daughter products, and that lots of collisions make matter hotter and brighter generally, and also more likely to densify into e.g. stars, which are ultimately mostly very hot very frequently colliding very visible matter).

Cold dark matter mostly behaves like heavy neutrinos. Known neutrinos are "hot" because they are so low mass that they are hard to keep from accelerating to speeds comparable to the speed of light, and thus can't keep their (individually low, but collectively less low) mass localized around a galaxy cluster. Neutrinos also interact only via the weak force, so while there are trillions passing through you as you read this, probably none at all will be "felt" by any of the regular matter in your body. But they are matter, and they have been observed in laboratory experiments since 1959, and solar neutrinos have been spotted in detectors in more recent decades.

There are also almost certainly cold regular neutrinos that have redshifted as a relic field, like the cosmic microwave background (a relic field of neutrinos). They will be much much harder to detect because the recoil of atomic nuclei encountering a cold regular neutrino will be much smaller than one encountering a neutrino moving relativistically.

We may at some point be able to doppler-cool neutrino emitting substances, producing cold regular neutrinos in terrestrial laboratories.

So the missing piece is preventing already-cold neutrinos from heating up (extra mass can do that, so can a lower interaction cross-section, e.g. gravitation-only interaction rather than weak force interaction; both can combine). Consequently, the existence of a CDM particle is not much of a stretch, particle physicists are doing what they can to try to find it (and block out interaction cross-section vs mass areas that have been probed without finding a CDM particle), and observational astrophysicists are also looking for evidence from cosmic rays and their sources (e.g. supernovae).
There is still a lot of room for a CDM particle to be hiding, and there is a lot of not-so-low-hanging fruit that will have to be probed. :-(

There are quite a few proposed extensions of the standard model (of particle physics) that have suggested places to look first, since a variety of sterile heavy neutrinos could fix some problems specific to the standard model (i.e., not involving gravitation at all). The LHC has killed off a few such particle-physics proposals, but certainly nowhere near all; it could still end up finding a particle (or more than one) that would be a good candidate for at least some of the observationally-inferred dark matter.