perhaps a further example will make it clear:
we want to factorise
so we can try some small integer values of x, and see if we find a point when g(x) = 0

So we have already found a value of x when g(x) = 0.
Now factor theorem states that: g(a) = 0 if and only if (x-a) is a factor of g(x)
Here a = 1
Therefore we know that (x-1) is a factor of g(x)
We could factorise g(x) on inspection now, or use long division or we could try some more values of x:
so (x-2) is not a factor.
This implies that (x+1) is a factor of g(x)
This implies that (x+2) is a factor of g(x)
Being a cubic, there must be at most three factors, and as we have found three we can say that:
to check, expanding the factors on the right yields the cubic equation, so it has been correctly factorise.
You might like to try and factorise: