I know that in mass spectrometry they charge different molecules and then run them through a magnetic field and then see where they land.
That is indeed how some mass spectrometers work, but not most of them. Most mass spectrometers in the world do not use magnets of any type. Instead they rely on electric fields to move the ions (i.e. charged molecules) and to see where they land.
Depending on this, they calculate their masses relative to each other. To do this however, they have to ionize the different particles evenly. If one molecule is charged +2 and the other +1, then the results would be thrown off.
Multiple charge states definitely happen in mass spectrometry. Mass spectrometrists like to say that name "mass spectrometry" is a misnomer, since nearly every "mass" spectrometer in the world is really a mass-to-charge ratio spectrometer. That is, MS doesn't measure the mass of molecules, it measure the mass-to-charge ratio (or $m/z$) of an ion.
The problem of multiple charge states is especially common in the mass spectrometry of proteins, because proteins are very large molecules with many sites that can become charged. For example, the image below
shows the "mass" spectrum (i.e. $m/z$ spectrum) of horse myoglobin, which is a compound with the formula of $\ce{C769 H1212 N210 O218 S2}$. The spectrum was obtained from this web page which further describes the multiple charge state phenomenon.
The different peaks correspond to different charge states. The uncharged molecule has a mass of 16951 Daltons. The peak at an $m/z$ 737.99 corresponds to a +23 charge state, and the peak at 1542.02 corresponds to a charge state of +11. The peaks in between correspond to charge states from +22 to +12.
How do they do they make sure that the charges of all the ions are the same?
There is no foolproof way to do this chemically or physically. Some modes of ionization, such as electron ionization or APCI tend to favor the formation of singly-charged ions relative to electrospray ionization, but these modes of ionization are sadly ineffective on large molecules such as proteins. And there are many exceptions to this tendency.
The mass spectral data can be manipulated computationally through a process called deconvolution in an attempt to computationally estimate the true mass spectrum at a given point. A 1992 paper describes one computational method for spectral deconvolution. This and/or very similar algorithms are often provided by mass spectrometer vendors in their software for browsing and analyzing MS data.