A spark excites a resonant electrical oscillation.
Hertz used an AC RLC system whose resistance, inductance and capacitance set a resonant frequency. High voltage across a small gap broke down the air and created a spark. The resulting rapid oscillation of charge in the loop produced changing electric and magnetic fields.
Those fields did not remain confined to the wire. Part of the energy radiated outward as electromagnetic waves, exactly as Maxwell's theory predicted.

