For f(g(x)) to be defined, the range of g must be in [2,inf). Now the range of g, quite obviously, is [a,inf] so for this to fit inside the domain of f, we have a >= 2 (if a = 3, for instance, the range of g is then a subset of the domain of f, which is fine)

For g(f(x)) to be defined, the range of f must be in (-inf, 1], and the range of f is (-inf, a-2]. For (-inf, a-2] to be in (-inf, 1], we require a-2 <= 1, or a <= 3. Combining the two gives you 2<=a<=3.

You need to remember that f(g(x)) is defined even when the domain of f isn't equal to the range of g; the domain of f just has to include the range of g.