When an EM wave is created,
The electromagnetic wave is a classical wave, a solution of classical maxwell's equations, it has a frequency nu and propagates as varying electric and magnetic fields
Electromagnetic waves can be imagined as a self-propagating transverse oscillating wave of electric and magnetic fields. This 3D animation shows a plane linearly polarized wave propagating from left to right. Note that the electric and magnetic fields in such a wave are in-phase with each other, reaching minima and maxima together
Then you say:
the source emits Photons with Energy X.
Photons are quantum mechanical entities, each described by a wavefunction which is the solution of a quantized maxwell's equation .
This image can give an intuition on how the photons, which are elementary particles and are characterized only by their energy=h*nu and their spin, add up in great numbers to build up the classical wave.
The photon wavefunction, a complex function, has the E and B information, and the superposition of the wavefunctions builds up the classical wave. This can be seen mathematically in this link, but it needs familiarity with quantum field theory.
The photons and the beam they build up does not depend on a medium unless in transparent matter where a beam can propagate, when it will be affected by the lattice fields by the interaction of the photons with the lattice.