Magnetization reversal in a site-dependent anisotropic Heisenberg ferromagnet under electromagnetic wave propagation