STM's work on an entirely different principle, called quantum tunnelling, which is ludicrously complicated mathematically, but can be summed up as the ability for particles to "tunnel" at small scales through barriers where they really shouldn't. In the case of an STM you have a probe tip and a sample which are both conductive, so if you apply a voltage to one of them, electrons will try to jump between them. The probe is far enough from the sample that the only way for any current to flow is through quantum tunneling. That current (somewhat bizarrely) a function of the number of states available to the electron, which increases as you move over atoms and decreases in the space between them. It's this change in current, mapped over the whole sample, that lets us "see" atoms.