Why do lasers require mirror at the ends? Laser uses mirrors to reflect photons in order to stimulate atoms to emit photons, but why this is so?. I mean, why does a photon stimulate atoms to produce more photons? If a photon made an atom to produce a photon, is not the first photon absorbed by the atom and therefore there is not total gain in the process?
 A: Lasers are pumped, so that many electrons already have excited states. In such a situation, when a photon passes through the active material, it's unlikely to be absorbed because there's not enough electrons in non-excited states. Much more likely result is that, by mechanism of stimulated emission, excited electrons can lose their energy, producing a duplicate of the photon which passed by. This happens when passing photon has energy very close to energy of radiative transition from excited state to non-excited. 
Mirrors make up the optical cavity, which makes photon travel multiple times across the active material, thus making more and more photons duplicate, resulting in exponential growth of electromagnetic energy, which partially exits the cavity because one (or both) of mirrors are not 100% reflective. And the light which exits is the usable light from laser.
A: The light returned to the laser is used as feedback to mantain the light emitted at a certain frequency. This is done in the same way a swing must be pushed at a certain frequency so that it can mantain its oscilation despite the energy losses due to air drag. The atoms loose energy in the form of radiation, but they recieve energy to sustain this output (usualy in the form of some electrical current). The purpose of the returning photons is to keep the emission spectrum as monocromatic as possible.
A: *

*the mirrors create an optical cavity (to trap photons in the gain medium as long as possible for stimulated emission to occur), which is one of the essential elements of a laser

*the second element is a pumping method, which places the electrons or dimers in their excited states. the simplest method is to use a normal light source which produces photons of higher energy than those expected to be released as laser light. another method is high voltage discharge.

*therefore an absorbed photon is not the same as a stimulating photon. a stimulating photon triggers emission from an electron of excited state without itself being changed--there are now two identical photons, but only one was produced from the relaxation of the excited state. therefore the quantum efficiency is at most 100% (in the case of successful stimulation).
A: I'd like to add to Ruslan's, Gregsan's and Oscar Lazo's answers, particularly Oscar's. All these answers are perfectly valid. The multiple bounces in a laser raise the probability of a given photon's stimulating another in a stimulated emission event AND shape the output spectrum. But why is there a spectrum to shape? And how does the cavity shape the spectrum?

The Shape of the Spectrum Without a Cavity
A laser pulse always begins as spontaneous emission. As the spontaneous emission travels through the gain medium, relatively coherent stimulated emission joins the pulse. 
It's important to understand spontaneous emission can have a wide wavelength spread - it's wavelength is not simply the zero uncertainty value implied by the $h\,\Delta \nu$ step between atom energy eigenstates. The emitting atom is coupled to all modes of the quantized electromagnetic field, so there is a range of wavelengths it can emit in. This is the precisely the same mechanism that begets the Lamb shift between otherwise degenerate eigenstates of e.g. the Hydrogen atom as reckoned by the Dirac equation. Also, especially  in gas lasers, spontaneous emission wavelengths are further broadened by Doppler shifting. Doppler shifting and other thermalisation effects are always present, but the fact that the atom is a coupled quantum oscillator rather than simply that described by the bare Dirac equation is a fundamental, inescapable reason why there is always wavelength spread, even in cryogenically cooled lasers.
If $\hat{a}_0^\dagger$ is thought of as the creation operator for a raised gain atom state and $\hat{a}_\pm^\dagger(\omega)$ the corresponding operator for a photon in a one dimensional quantized EM field at frequency $\omega$ and in right (+) or left (-) circular polarisation, the Hamiltonian has the form:
$$\hat{H} = \hbar\left(\omega_0 \hat{a}_0^\dagger \hat{a}_0 + \int_0^\infty \omega\,\left(\hat{a}_+^\dagger(\omega) \hat{a}_+(\omega)+ \hat{a}_-^\dagger(\omega) \hat{a}_-(\omega)\right)\,\mathrm{d}\omega +\\ \int_0^\infty \left(\kappa_+(\omega)^*\, \hat{a}_0^\dagger \hat{a}_+(\omega) + \kappa_+(\omega) \hat{a}_+^\dagger(\omega)\,\hat{a}_0\right)\,\mathrm{d}\omega + \int_0^\infty \left(\kappa_-(\omega)^*\, \hat{a}_0^\dagger \hat{a}_-(\omega) + \kappa_-(\omega) \hat{a}_-^\dagger(\omega)\,\hat{a}_0\right)\,\mathrm{d}\omega + const\right)\quad\quad\quad(1)$$
where $\kappa_\pm(\omega)$ is the coupling strength between the excited atom and the free photon electromagnetic modes. I just write this down as a general linear coupled model, make the assertion that the $\kappa_\pm(\omega)$ can be calculated in principle from quantum electrodynamics and thus give the impression that I know how to do such a thing (I don't!). With only one photon in the system (i.e. initially in the excited atom and being spontaneously emitted into the field) and given that the above Hamiltonian conserves photon number (adds a photon whenever one is taken from somewhere else), we can reduce the whole system state to the probability amplitude $\psi_0(t)$ of the emitter atom's being excited together with the continuous functions $\psi_\pm(\omega)$ which are the probability amplitudes to find the photon in the mode with frequency $\omega$ and in left and right hand circular polarisation:
$$\begin{array}{lcl}
i\,\mathrm{d}_t\, \psi_0(t) &=& \omega_0 \,\psi_0(t) + \int_0^\infty \left(\kappa_+(\omega)^* \,\psi_+(\omega, t)+\kappa_-(\omega)^* \,\psi_-(\omega, t)\right)\, \mathrm{d}\omega\\
i\,\partial_t \,\psi_\pm(\omega, t) &=& \omega\, \psi_\pm(\omega, t) + \kappa_\pm(\omega) \,\psi_0(t)\end{array}\quad\quad\quad(2)$$
This can be re-arranged to eliminate $\psi_\pm(\omega)$ and leave an integro-differential equation in $\psi_0$ alone, which can be solved, whence the $\psi_\pm(\omega)$ can be calculated.
$$  {\rm{\psi}}_+
  \left({{\rm{\omega,t}}}
  \right)
  =i\,{\rm{\kappa}}_+
  \left({\rm{\omega}}\right)
   \int \limits_{\rm{0}}^
   {\rm{t}}
   {
    e^
    {
     i{\rm{\omega}}
     \left({{\rm{u}}-{\rm{t}}}
     \right)
    }
    \,{\rm{\psi}}_{\rm{0}}
    \left({\rm{u}}\right)
    {\rm{du}}\,
   }
  ;\quad{\rm{\psi}}_-
  \left({{\rm{\omega,t}}}
  \right)
  =i\,{\rm{\kappa}}_-
  \left({\rm{\omega}}\right)
   \int \limits_{\rm{0}}^
   {\rm{t}}
   {
    e^
    {
     i{\rm{\omega}}
     \left({{\rm{u}}-{\rm{t}}}
     \right)
    }
    \,{\rm{\psi}}_{\rm{0}}
    \left({\rm{u}}\right)
    {\rm{du}}\,
   }
  \\
  \frac{
   d\,{\rm{\psi}}_{\rm{0}}
   \left({\rm{t}}\right)
  }{dt}
  =\,-i\,{\rm{\omega}}_{\rm{0}}
  {\rm{\psi}}_{\rm{0}}
  \left({\rm{t}}\right)-
  \int \limits_0^t
   {
    R \left({{\rm{t-v}}}\right)\,
    {\rm{\psi}}_{\rm{0}}
    \left({\rm{v}}\right)
    {\rm{dv}}
   }
  ;\quad R
  \left({\rm{t}}\right)=
  \int \limits_0^\infty
   {
    e^
    {-i\,{\rm{\omega}}\,{\rm{t}}}
    \left(
     {
      \left|
       {
        {\rm{\kappa}}_+
        \left({\rm{\omega}}\right)
       }
      \right|
      ^2+
      \left|
       {
        {\rm{\kappa}}_-
        \left({\rm{\omega}}\right)
       }
      \right|
      ^2
     }
    \right)
    {\rm{du}}
   }
  {\rm{;}}\quad\quad\quad(3)$$
An approximate solution to the above can readily be gotten by assuming a Lorentzian lineshape for the coupling $\kappa_\pm(\omega)$ and then letting the linewidth $\to\infty$. The result is:
$$  {\rm{\psi}}_{\rm{0}}
  \left({\rm{t}}\right)
  \approx \exp
  \left(
   {
    -i\,{\rm{\omega}}_{\rm{0}}\,
    {\rm{t}}-
    \frac{{\rm{t}}}{{\rm{2\tau}}}
   }
  \right)\quad
  {\rm{\tau}}
  \approx
  \left.
   {
    \frac{1}{
     {\rm{2}}\,{\rm{\pi}}\,\,
     \left(
      {
       {\rm{\kappa}}_+^2+
       {\rm{\kappa}}_-^2
      }
     \right)
    }
   }
  \right|_{{\rm{\omega}}={\rm{\omega}}_{\rm{0}}}\quad\quad\quad(4)$$
and thus we get the exponential, memoryless decay of a spontaneously emitting atom. Note that the linewidth depends only on the strength of coupling $\kappa_\pm(\omega)$ in the neighbourhood of the uncoupled transition frequency $\omega_0$ defined by the atom's transition energy level difference. It does NOT depend on the shape of the coupling  $\kappa_\pm(\omega)$ as long as this latter is broadband. What's going on intuitively? The atom is coupled to all modes roughly equally. However, it cannot emit into all equally, because if it couples to a frequency away from $\omega_0$, destructive interference hinders the process. So only frequencies near $\omega_0$ are excited. The behavior of Eq. (4) implies a Lorentzian lineshape in the frequency domain, thus we can understand the mechanisms behind the most common spontaneous emission lineshape.
Wigner-Weisskopf theory is another, equivalent description of the spontaneous emission process (V. Weisskopf and E. Wigner, Z. Phys. 63, 54 (1930)). The above is my own simplification presented in J. Opt. Soc. Am. B, Vol. 24, No. 6 June 2007 pp1369-1382.
It is important to understand that the linewidth (proportional to ${\rm{\kappa}}_+^2+{\rm{\kappa}}_-^2$) is often far too wide for applications. So the cavity, as well as increasing the probability of stimulated emission by recirculating light, also plays a crucial role in narrowing the basic spectrum of Eq. (4) as in the following.

How Do Mirrors Shape a Spectrum?
Spontaneously emission happens in all directions as well as over a frequency range. Simply put, the resonant cavity selects for propagation direction and frequency. It is straightforward to see how it selects for direction: obliquely propagating fields crash into the sides of the cavity and get absorbed. Selection for frequency, however, is much more involved (an example of Purcell Enhancement (see the Wikipedia page).
Since you accepted Ruslan's answer, you know what stimulated emission is, but if you've not already done so, you may like to look up Wikipedia's exposition on Stimulated Emission AND the Einstein Coefficients. If you understand how an electronic amplifier becomes an oscillator through positive feedback, then the same process is happening in a laser: the pumped, gain medium is an amplifier and mirrors, forming an Optical Cavity (often a Fabry–Pérot interferometer ) are the analogue of an LC resonant filter (or crystal filter) that chooses which frequency components are fed back into the amplifier. Notice how if you set up a microphone near speakers outputting the amplified former's output and speak into the microphone, the "feedback" doesn't manifest itself as an echo of your voice getting louder and louder. The feedback is often a pure tone: all the Fourier components of the noise into the microphone are amplified at first, but the most gain is imparted to those which come back, after the loop delay, to the microphone in-phase with original signal. So these get more gain than the others and if, say, the loop gain for two similar amplitude Fourier components is $A_1$ and $A_2$, then after $N$ loop recirculations the ratio of the component amplitudes is $(A_1 / A_2)^N$. The system thus swiftly selects a narrow range of frequencies. The full story of how the loop's phase helps selection through constructive interference is quite complicated, because the pulse builds up exponentially with time owing to the gain medium and recirculations and only reaches a steady state when the pulse is big enough that it stimulates emissions at exactly the same rate as the gain atoms are being pumped into their excited states, so this is modeled by solving nonlinear rate equations. But you can get an intuitive feeling for how the cavity selects special wavelenths (and, indeed propagation directions) from the linear response of the Fabry-Pérot laser cavity as follows. 

My drawing shows a cavity comprising a full reflector at one end, and a partial reflector (to get our laser light out of the cavity) at the other. We assume there is one resonant spatial mode in the cavity (e.g. the fundamental Hermite-Gauss or Laguerre-Gauss mode). The mirror's action is characterized by its scattering matrix relating the reflected wave amplitudes $b_1,\,b_2$ linearly to the incident wave amplitudes $a_1,\,a_2$. For a lossless mirror, the scattering matrix is unitary, and, given the symmetry of the mirror's action (if it works the same whether flipped over or not) the most general $2\times2$ unitary relationship is:
$$\left(\begin{array}{c}b_1\\b_2\end{array}\right) = e^{i\,\alpha}\left(\begin{array}{cc}\cos\phi&i\,\sin\phi\\i\,\sin\phi&\cos\phi\end{array}\right)\left(\begin{array}{c}a_1\\a_2\end{array}\right)\quad\quad\quad(5)$$
Now if we were to second quantize the one-dimensional EM field in this problem, we might use a long, length $L_Q$ quantisation volume as sketched at the bottom of my drawing and we write down the eigenmodes of this system. If the cavity's there and back length is $L$, so that the "output" $b_1$ is fed back into the input $a_1$ through the optical the loop phase delay $\exp(i\,2\,\pi\,n\,L/\lambda)$ where $n$ is the cavity's effective refractive index and $\lambda$ the freespace light wavelength, then Eq. (5) together with the equation $a_1 = \exp(i\,2\,\pi\,n\,L/\lambda)\, b_1$ (assuming that $\lambda$ is one of the system modes allowed by the quantisation length $L_Q$ - we assume $L_Q\to\infty$ so that the allowed values of $\lambda$ become more and more densely packed) we can show that the monochromatic system modes are defined by the following relationships between the amplitudes of the wave $a_1$ in the cavity the wave $b_2$ scattered by the cavity and the wave $a_2$ incident on the cavity:
$$b_2 = a_2 \frac{e^{i \alpha } \left(-\cos\phi+\exp\left(i \left(\alpha +\frac{2 \pi  L n}{\lambda }\right)\right)\right)}{-1+\cos\phi \exp\left(i \left(\alpha +\frac{2 \pi L n}{\lambda }\right)\right)}\quad\quad\quad(6)$$
$$a_1 = a_2\frac{i \sin\phi \exp\left(i \left(\alpha +\frac{2 \pi  L n}{\lambda }\right)\right)}{1-\cos\phi \exp\left(i \left(\alpha +\frac{2 \pi  L n}{\lambda }\right)\right)}\quad\quad\quad(7)$$
The ratio $b_2 / a_2$ has unit magnitude (to see this, take heed that the numerator is a unit magnitude phase factor time the conjugate of the denominator), so nothing unforeseen here - this has to be so by energy conservation (there is no loss in the cavity and energy cannot get out though the full mirror at the left hand side of my drawing). But now let's look at the and the ratio $a_1 / a_2$ of the cavity field amplitude to that of the field outside, supposing that the mirror is designed so that $\phi$ is small, i.e. it is almost fully "silvered". A given photon's number of recirculations is then exponentially distributed with the recirculation number $N$:
$$p(N) = \sin^2 \phi \, \cos^{2 (N-1)} \phi\quad\quad\quad(8)$$
and the mean number of recirculations is $\sum\, N\, p(n) = (\sin\phi)^{-2}$, so each photon travels a mean length of $L / \sin^2\phi)$ through the gain medium before escaping to the output. This factor $(\sin\phi)^{-2}$ which defines how much the cavity's length is magnified by the multiple bounces is called the cavity's Finesse. I plot below the ratio $|a_1 / a_2|^2$ when $\phi = 0.05$ as a function of wavelength $\lambda$ around $\lambda = 1$ unit, so that we have a finesse of roughly 400 (a pretty high quality cavity) and a cavity length of nominally $10000\lambda$; here I assume that the common mode phase delay $\alpha$ is nought and with vacuum in the cavity. I have included a plot of a the central peak at $\lambda = 1$ and also a log-log plot over a much wider (but still narrow) wavelength range to show the wavelength-periodic behavior - the cavity is said to have a free spectral range of $\Delta \lambda = 10^{-4}$ units (i.e. this is the periodicity in wavelength).


What is the point of all this? In this second quantized picture, the modes pass through the cavity almost as though it weren't there aside from when resonance traps them in the cavity. Therefore, these resonant modes are the special ones whose photons linger in the cavity much longer than those in other system modes. So if a spontaneous emission from an atom in the cavity adds one photon to any mode, this photon's field of influence is spread thinly over the whole, length $L_Q$ system if the mode is not a resonant one. Such photons therefore will not be amplified, or only so at tiny probability. It is only photons emitted into the resonant modes that stand a chance of stimulating an emission, thus adding another photon to the same mode and so on, because these are the ones whose field of influence is much more tightly confined to the cavity. This is the intuitive reason for how the cavity shapes the spectrum of the spontaneously emitted photons.
The above mechanisms, whereby a resonant cavity alters the second-quantized mode structure to suppress coupling in certain modes or bands of modes is an example of Purcell Enhancement (see the Wikipedia page). The one dimensional resonant cavity above is maybe the simplest manifestation of this effect.
Note that the Lorentzian lineshape in (4) can be wider than the cavity's free spectral range, so significant engineering is needed to prevent all but the central cavity mode bearing light. Even so, lasers can have several fine lines in their spectrum, and they can spontaneously "mode-hop" between lines of the cavity within the basic emission band defined by Eq. (4) owing to the system's sensitivity to vibration, variable strains owing to temperature drift and so forth.
