Suppose not. Then we can take some $\varepsilon$ such that no matter how big $K$ is, $f(t)$ is more than $\varepsilon$ away from $a$ for some $t>K$.
Now by assumption, there exists $M$ big enough that $f(g(y))$ is within $\varepsilon$ of $a$ when $y$ is bigger than $M$. Now let $K=f(M)$. By our first statement, there exists $t>K$ such that $f(t)$ is more than $\varepsilon$ away from $a$. But since $g(x)$ approaches infinity, there must be a point $y>M$ where $g(y)>t$. By the Intermediate Value Theorem, there is some $x\in(M,y)$ such that $g(x)=t$.
And now we have a contradiction: Since $x>M$, $f(g(x))$ is within $\varepsilon$ of $a$. However, $g(x)=t$, so by the definition of $t$, we know that $f(g(x))$ is more than $\varepsilon$ away from $a$.
Incidentally, the continuity is really important. Otherwise, we could let $g$ be the floor function, and let $f$ be some function that gets close to $a$ for integers, but moves far away for values between integers.