Does the Rayleigh formula apply to electron microscopes or only light microscopes?
This is more than likely better asked in physics SE, however since you contextualized it biologically somewhat I will answer it here.

You are correct in your concern. The Rayleigh Criterion and the associated calculations(Rayleigh Scattering) are talking about the minimum separation of 2 light sources to resolve a given object. From this we are able to derive nice metrics like resolution and so forth. As you say, this describes the resolving of light wrt to the diffraction limit.

In order to calculate the resolving power of an SEM or TEM you need to do a different set of calculations.

First, the theoretical limit of EM microscope resolution is given by the De Broglie Wavelength of the accelerated electrons. However, as with the calculations for the Rayleigh Criterion, there are other factors to consider. For a full walkthrough see this. You take Abbe's equation for resolution in a perfect optical system, and take account of the other factors at play(optics for example).