Electromagnetic lenses operate by creating a controlled magnetic or electric field that influences the trajectory of charged particles, such as electrons. By adjusting the strength and configuration of these fields, the lenses can focus or deflect the electron beam to achieve the desired imaging or manipulation effect.