Let's say you already know (in the given context) the definition of injection.
For arbitrary x and y in A, suppose that over in B, f(x) = f(y).
This identity should tell you that (over in C) the image of f(x) under g is identical to the image of f(y) under g, i.e., that g(f(x)) = g(f(y)).
This can be written, (gof)(x) = (gof)(y).
Since gof is injective, you now have x = y (by definition).
So the arbitrariness of x, y and the supposition that f(x) = f(y), leads you to x = y, making f injective (by definition).