Mass approaching light velocity

We know that, photons have zero mass as the travel at the ultimate velocity “c”.Following the Lorentz transformation equation, we see that an object approaching that velocity gains mass.Why are both the incidents opposite?

I don't know that anybody has the full answer as to why this is the case. For Einstein and Poincaré, the invariance of the speed of light was a postulate. The non-linear nature of momentum was a consequence of that assumption.

I will suggest that it is best to think of mass as invariant, and to think of energy-momentum as that quantity which looks different when seen from relatively moving reference frames.

See page 246 (leaf 257) of Spacetime Physics Introduction To Special Relativity [ Taylor Wheeler] PDF Use and abuse of the concept of mass.

To avoid free interpretations of SR (special relativity) we have to stick to the tensorial formalism which requires invariant objects.
Let us consider the Lorentzian four-momentum:
$p^μ = m dx^μ / dτ$
where:
$μ = 0, 1, 2, 3$
$p^μ$ = four-momentum
$x^μ$ = (ct, x, y, z)
$m$ = rest mass
$τ$ = proper time
As $dt/dτ = γ$, and showing correct units we have $γmc = E/c$,
where:
$γ = 1 / \sqrt{1 − v^2/c^2}$ Lorentz factor
$v$ = Newtonian velocity
Hence:
$p^μ = (E/c, p^i)$
where:
$i = 1, 2, 3$
The mass of a particle is the rest mass. The $\gamma$ factor accounts for the fact that in order to accelerate a particle to the speed of light you need an infinite energy. However as for massless particles (photons), assuming that the momentum is finite, you may think that as $v$ approaches $c$ the rest mass $m$ tends to zero so that the product $γm$ remains finite. This is a remarkable achievement of SR, as it demonstrates that a massless particle moves at the speed of light.