But how do you apply this with Lorentz’ transformation (i.e. relativistic factors)? You cannot approach the speed of light without considering relativism. It is known that p = gamma * m * v where p is momentum, gamma is the gamma factor given by sqrt(1/(1 - (v^2/c^2))), m is mass and v is velocity. If you study the gamma factor, you’ll realize that it approaches infinite as v approaches c, the speed of light. Since we are actually dealing with light here, where v = c we are breaking the equation. Momentum cannot be defined for any mass which moves at the speed of light. It’s asymptotic at that speed.
Also note that the same goes for E = mc^2. At relativistic speeds, also this equation needs to consider the gamma factor. So those classical equations break down for light.
The answer is that photons don’t have mass, but they have energy. There is a good explanation a bit further up in this thread on how this is possible.