An electromagnetic wave doesn't violate the conservation of energy. Maxwell's electromagnetism does. When you apply the Maxwell's equations to two beams of light of the same frecuencyfrequency, collinear, out of phase 180 degree, occurs the phenomenon of destructive interference. In this special case the electric field of one wave is cancelledcanceled with the electric field of the other wave; the same happens with the magnetic fields. Both fields become zero. Following Maxwell the energy is contained only in those fields.
Let make the math: Let us have these two waves: Be E$E$ = electric fiel; B=magneticfield; $B$=magnetic field
E1 = Em sin (kx - wt) E2 = Em sin (kx - wt + p) B1 = Bm sin (kx - wt) B2 = Bm sin (kx - wt + p)$$E_1 = E_m \sin (kx - \omega t), \quad E_2 = E_m \sin (kx - \omega t + p)\\ B_1 = B_m \sin (kx - \omega t), \quad B_2 = B_m \sin (kx - \omega t + p) $$
E = E1 + E2$E = E_1 + E_2$ and B = B1 + B2
E = Em sin (kx - wt) + Em sin (kx - wt + p)$B = B_1 + B_2$
B =Bm sin (kx - wt) + Bm sin (kx - wt + p)\begin{align} E &= E_m \sin (kx - \omega t) + E_m \sin (kx - \omega t + p) \\ B &=B_m \sin (kx - \omega t) + B_m \sin (kx - \omega t + p) \end{align}
But, sin (kx - wt + p) = - sin (kx – wt)$\sin (kx - \omega t + p) = - \sin (kx – \omega t)$ ,
Then, E = 0$E = 0$ and B = 0$B = 0$ and,
UT = UE + UB
UT = ½ eOE2 + ½mOB2
UT = 0\begin{align} U_T& = U_E + U_B \\ &= \frac12 \epsilon_0E^2 + \frac12\mu_0B^2 \\ &= 0 \end{align}
According to Maxwell equations, in destructive interference of two collinear beams out of phase 180 degree, the energy density, which is a function of the electric and magnetic fields, is destroyed too. In this way, the principle of conservation of energy is violated.