Given real functions $f, g$, we can say
$$\lim_{x \to a} f(g(x)) = f\left(\lim_{x \to a} g(x)\right) \tag{$\star$}$$
in the following circumstances:
- If $L = \lim_{x \to a} g(x)$ exists and $f$ is continuous at $L$, or
- If $L = \lim_{x \to a} g(x)$ exists, $g(x) \neq L$ for $x$ sufficiently close to $L$, and $\lim_{x \to L} f(x)$ exists.
The second case holds in the given question (note how $g(x) \neq 2$ for $x$ close to $0$), so we can still indeed use $(\star)$.
There are finer versions of this that may be helpful in certain circumstances. Consider the following limit given the above graphs:
$$\lim_{x \to 3} f(g(x)).$$
Neither of the above conditions hold, since the limit $\lim_{x \to 1} f(x)$ does not exist. But, since $g(x) < 1$ for $x$ close to, but not equal to $3$, this tells us that
$$\lim_{x \to 3} f(g(x)) = \lim_{x \to 1^-} f(x) = 2,$$
since $g(x)$ is producing function values close to but less than $1$, and we are substituting them into $f$.
I wouldn't look for a complete set of steps to solve problems like these. Try to build an intuition for what is going on.