In the following video (, diagram also given for reference), the professor says that if the graph peaks in a short wavelength, then the star is a hot star (or galaxy) and if it does so in a long wavelength, then it's a cold one. However, I fail to understand this. How does it happen that if a star emits more energy in shorter wavelengths, then it's a hot star and a cold one if it does so in longer wavelengths?

This has to do with the property of the black-body spectrum. As a first idealisation, most stars can be well-approximated as behaving as blackbodies, and so the spectral distribution of the emitted radiation follows what is known as the black-body spectrum, which has a general shape resembling what you've drawn there: the power increases quite quickly to a peak value and then exponentially falls off as the wavelength increases.

More explicitly, it follows the celebrated Planck's law:
[tex]E_{\lambda}(\lambda,T) \propto {2 h c^2\over \lambda^5}{1\over e^{h c/\lambda k_{B}T}-1}[/tex]
With some calculus, you can work out the wavelength at which the peak occurs, and this result, ##\lambda_{peak} = \frac{2.898\times 10^{-3}}{T}##, is known as Wien's displacement law.

This is why the peak wavelength of the emission is in fact inversely proportional to the temperature of the star.