You are correct that in a vacuum, electromagnetic (EM) waves do not interact directly with the particles or objects they encounter. However, the phenomenon you are referring to, the loss of energy as EM waves travel across vast cosmic distances, is primarily due to the expansion of the universe.
As the universe expands, the space through which the EM waves propagate also expands. This expansion leads to a phenomenon called cosmological redshift. Redshift occurs because the stretching of space increases the wavelength of the EM waves, shifting them towards the longer wavelength (red) end of the electromagnetic spectrum. This shift corresponds to a decrease in energy.
The cosmological redshift affects all types of electromagnetic radiation, including visible light, radio waves, and X-rays. As a result, EM waves from distant sources, such as supernovae billions of light-years away, undergo redshift as they travel towards us. The amount of redshift depends on the distance between the source and the observer and is proportional to the expansion of space during the time the light has traveled.
It's important to note that the expansion of space itself is responsible for this energy loss, not interactions with matter or other particles. The EM waves are simply stretched out as the universe expands, causing a decrease in their energy. This phenomenon is a consequence of the general relativistic nature of the expanding universe.
In summary, the loss of energy of electromagnetic waves from distant sources, like supernovae, is primarily attributed to cosmological redshift resulting from the expansion of the universe. It is not a direct interaction with matter but rather a consequence of the stretching of space during the propagation of light over cosmic distances.