From the fact q(a,g(b)) you cannot infer whether q(a,g(a)) is in the model. First you need to generate a model.
To determine the model, start with the facts {q(a,g(b)), q(b,g(b))} and now try to apply your own rules to expand it. In your case, however, there is no way to map the right side of the rule q(X,g(X)) :- q(X,g(g(g(X)))). with the facts above. So you are done.
Now imagine the rule
q(a,g(Y)) :- q(b,Y).
This rule can be used to expand our set. In fact, an instance
q(a,g(g(b))) :- q(b,g(b)).
: If q(b,g(b)) present, enclose q(a,g(g(b))) . Please note that we use the rule from right to left here. So, we get
{q(a,g(b)), q(b,g(b)), q(a,g(g(b)))}
thereby reaching a fixed point.
Now take as another example you proposed a rule
q(X, g(g(g(X)))) :- q(X, g(X)).
Which allows (I will no longer show the created rule) for generation in one step:
{q(a,g(b)), q(b,g(b)), q(a,g(g(g(b)))), q(b, g(g(g(b))))}
But this is not the end, since again the rule can be applied to get even more! In fact, you now have an endless model!
{g (a, g n + 1 (b)), g (b, g n + 1 (b))}
This right-to-left reading is often very useful when you are trying to understand recursive rules in Prolog. Reading from top to bottom (left to right) is often quite difficult, in particular, since you have to consider rollback and general unification.