If light has no mass, why it is attracted by a black hole? Like, if the force is g = m.a then the attraction would be 0 and the photon would just pass by?
A photon isn't actually attracted by a black hole, but its geodesic may cause it to enter the black hole.
Photons of light have zero mass. This means that they travel at the speed of light. Interestingly photons do not experience time as a consequence.
Einstein showed through his General Theory of relativity (GR) that gravity is not a force. Mass, energy and momentum curve space time. Space time being 4 dimensional. Gravity is actually an acceleration caused by the curvature of space time.
The Einstein equations may look very simple. In fact they are most definitely not. The field equations are:
The left hand side describes the curvature of space time and the right hand side describes the mass, energy and momentum which cause the curvature. The equation is actually 10 second order partial differential equations!
In the absence of an external force all objects move in a straight line with constant, possibly zero, velocity. In curved space time the straight line becomes a geodesic which is the shortest distance between two points in space time.
So, as gravity is not a force, nothing is attracted by a black hole. Objects simply follow a geodesic. This also includes light photons.
If a photon passes near to a black hole its geodesic path will be bent around the black hole but it won't enter it. If the photon is headed towards the black hole the geodesic will intersect the event horizon and the photon will be consumed.