I am confused about exactly how does NMR machine figure our area under each peak, which then tells us how much protons present in the molecule. Does it have to do something with radio waves being emiitted after proton relaxes? Thanks.
The modern basic FT 1H NMR experiment involves irradiating and simultaneously exciting a wide bandwidth of proton frequencies. That is to say, all spin populations of the proton nuclei have their spin state reversed with a carefully calibrated Rf pulse that delivers the correct amount of power for the correct duration. As each spin relaxes back to equilibrium, it emits a photon of Rf energy. So, yes your assumption is pretty well correct. This energy packet has a specific frequency (a product of the chemical shift), and a specific intensity - it is a quantum packet of energy. If two nuclei of the same frequency each emit a photon of energy, the intensity of that frequency detected will be twice as large a single nucleus emitting a photon of energy.
Across the entire frequency range, the data collected in the free induction decay is the sum product of all frequencies, and their intensities. The Fourier transform function then converts this time domain data into the preferred frequency domain spectrum.