The mass of a photon is zero but why does it have a momentum and an energy (E=mc^2=hv) ?
This is only true for objects at rest, and photons are not at rest.
The more general formula is ##E^2 = m^2 c^4 + p^2 c^2##. There is nothing wrong with a massless particle having momentum and energy.
There's nothing in the laws of physics that prevent a particle from having zero mass and nonzero momentum and energy. Mass, momentum, and energy are properties, so they are related. That relationship allows for zero mass along with nonzero energy and momentum. In fact, the same relationship asserts that if the mass is zero the energy and momentum have to equal each other.
But momentum is equal to p=mv so if m=0→p=0
No. See mfb's post #2.
I suspect you are getting confused by the so-called "relativistic mass" which almost no physicists use nowadays, but nevertheless survives in introductory (especially popular-level) treatments of relativity, versus the "invariant mass / rest mass" which Orodruin is referring to.
That only applies to objects with mass. For photons, the equation for momentum is p=hv/c, where h is Planck's constant, v is frequency, and c is the speed of light.
It sounds like something I would have said, but I have been silent in this thread so far.
There are Insights FAQs on both relativistic mass and on photons which are relevant. I suggest OP reads them.
And even for those, it is just an approximation for slow speeds.
@Gabriele Pinna: Formulas from nonrelativistic mechanics are just an approximation, they are good for slow objects, but they do not work for fast objects (a large fraction of the speed of light) and they are completely meaningless for light.
That used to be true in Newtonian mechanics, but it's not true in special relativity. See also the various comments about the ambiguities in the word "mass".
Separate names with a comma.