The answer is quite simple.
In a conventional microwave, the waves are spaced a certain distance apart, because that is all that is needed to cook the food properly.
The ants are so minute that they can dodge the rays and so survive the ordeal.
The phenomenon that the ants take advantage of is that microwaves form standing waves within the oven cavity.
So in some places in the oven space, the energy density is very high, whereas in others it is very low. This is why most ovens have turntables to ensure that cooking food is heated evenly throughout.
This standing wave pattern can be observed by putting a static tray of marshmallows in the microwave, and heating for a while. The result will be a pattern of cooked and uncooked marshmallows. The standing wave pattern, however, varies according to the properties and position of any material within the oven, such as a cup of water.
The ant will experience this pattern as hot or cold regions within the oven and can thus locate the low-energy volumes. If the ant is in a high-field region, its high surface-area-to-volume ratio allows it to cool down more quickly than a larger object while it searches for a cold spot.
It is a common myth that microwaves are too big to heat small objects.
The fallacy of this has been demonstrated by chemists such as myself who employ microwave heating in their work. Certain types of catalyst consist of microwave-absorbing particles, typically of submicron size, dispersed throughout an inert support material.
There is convincing evidence that microwaves are capable of heating only the tiny catalyst particles.
There is very little microwave energy near the metallic floor or walls of the oven.
The electromagnetic fields of microwaves are “shorted” by the conducting metal, just as the amplitudes of waves in a skipping rope, swung by a child at one end but tied to a post at the other, are reduced to nothing at the post. An ant crawling on the rope could ride out the motion near the post, but might be thrown off nearer the middle.
For a quick demonstration of this, place two pats of butter in a microwave in two polystyrene coffee cup bottoms, one resting on the floor, the other raised on an inverted glass tumbler. Be sure to place a cup of water in the microwave as well.
On heating, the raised butter will melt long before the butter on the floor.