Because a line always goes past the y-intercept and x-intercept. It's not always both, it can sometimes just be the x-intercept or the y-intercept.
When a line intersects these points, for example if a line was to intersect the x-axis then y would be equal to 0, and the opposite for the y-axis. If a line was to intersect the y-axis x would be equal to 0.
Therefore by using that knowledge, and the equation of the line [ y=mx+c or y-y1=m(x-x1) ], we can find the equation of our line. Of course you would need the gradient of that line (the value "m").