Changing the frequency can be done by changing the medium the light is passing through or by the doppler effect in extremely large distances.

As for the lasers, this is taken from Dr. Michio Kaku's book Physics of the Impossible:

In a laser you first begin with a special medium that will transmit
the laser beam, such as a special gas, crystal, or diode. Then you pump
energy into this medium from the outside, in the form of electricity, radio,
light, or a chemical reaction. This sudden influx of energy pumps
up the atoms of the medium, so the electrons absorb the energy and
then jump into the outer electron shells.
In this excited, pumped-up state, the medium is unstable. If one
then sends in a light beam through the medium, the photons will hit
each atom, causing it to suddenly decay down to a lower level, releasing
more photons in the process. This in turn triggers even more electrons
to release photons, eventually creating a cascade of collapsing
atoms, with trillions upon trillions of photons suddenly released into
the beam. The key is that for certain substances, when this avalanche
of photons is occurring all the photons are vibrating in unison, that is,
they are coherent.