How do electromagnetic waves transfer energy to matter?
The dirty details are discussed in the field of Quantum Electrodynamics, but basically photons interact with charged (and only charged) particles
While QCD is THE most accurate scientific theory humanity has discovered (created?), the mathematics behind it are a little advanced (It's usually a fourth-year or graduate course for a physics student). Nevertheless it boils down to: photons, the carrier particles of the electromagnetic force, interact with charged particles. In other words, they interact with the electron, muon, and tau. Muons and taus don't really exist for longer than few milliseconds, so the vast majority of electromagnetic waves interact with electron.
The transfer of energy is usually done by absorption and emission where the photon is absorbed or emitted by the electron. There is a set of phenomena called scattering where there is no absorption/emission but an interaction at a distance (mediated by a virtual photon), however that's a more specific case.