Proof of the continuity of composite functions in metric spaces. So, here's the result I'm proving:
Let $(X,d)$, $(Y,d')$ and $(Z,d'')$ be metric spaces. Suppose that the functions $f:X \to Y$ and $g: Y \to Z$ are continuous. Then, $g \circ f: X \to Z$ is continuous.

Proof Attempt:
Let $a \in X$ and $f(a) \in Y$. Then, $f$ is continuous at $a$ and $g$ is continuous at $f(a)$. If we prove continuity at this arbitrary point, then we would have proven continuity of $g \circ f$ at all points in $X$.
Let $\epsilon > 0$ be given. Since $g$ is continuous at $f(a)$, there exists a $\delta_2 > 0$ such that:
$$d'(f(x),f(a)) < \delta_2 \implies d''(g(f(x)),g(f(a)))$$
Since $f$ is continuous at $a$ and given the above $\delta_2$, there exists a $\delta_1 > 0$ such that:
$$d(x,a) < \delta_1 \implies d'(f(x),f(a)) < \delta_2$$
By the transitive law of implications, we see that:
$$d(x,a) < \delta_1 \implies d''((g \circ f)(x), (g \circ f)(a))$$
Define our desired $\delta = \delta_1$. Since it exists for any given $\epsilon$, it follows that $g \circ f$ is continuous at $a$. By extension, it is continuous. That proves the desired result.
Does the argument above work? If it doesn't, why? How can I fix it?
 A: Your proof sounds good. Here I provide an alternative way to prove it based on the sequential characterization of continuity. In order to do so, we shall need the following result:
Proposition
Let $(X,d_{X})$ and $(Y,d_{Y})$ be metric spaces and $x_{0}\in X$. We say that $f:X\to Y$ is continuous at $x_{0}$ if and only if for every sequence $x_{n}\in X$ which converges to $x_{0}$ w.r.t. $d_{X}$ implies the convergence of the sequence $f(x_{n})$ to $f(x_{0})$ w.r.t. $d_{Y}$.
Proof
Let us prove the implication $(\Rightarrow)$ first.
Let $\varepsilon > 0$. Then there exists a positive real number $\delta > 0$ s.t. for every $x\in X$ one has that
\begin{align*}
d_{X}(x,x_{0}) < \delta \Rightarrow d_{Y}(f(x),f(x_{0})) < \varepsilon
\end{align*}
Let us now consider that $x_{n}\in X$ converges to $x_{0}$ w.r.t. $d_{X}$.
Then for each $\delta > 0$ there corresponds a natural number $n_{0}\geq 0$ s.t.
\begin{align*}
n\geq n_{0} \Rightarrow d_{X}(x_{n},x_{0}) < \delta
\end{align*}
Gathering both results one concludes that for every $\varepsilon > 0$ there corresponds a natural number $n_{0}\geq 0$ s.t.
\begin{align*}
n\geq n_{0} \Rightarrow d_{X}(x_{n},x_{0}) < \delta \Rightarrow d_{Y}(f(x_{n}),f(x_{0})) < \varepsilon
\end{align*}
whence we conclude that $f(x_{n})$ converges to $f(x_{0})$ as $n$ approaches infinity, and we are done.
Let us prove the implication $(\Leftarrow)$ now. We shall prove it by contradiction.
In order to do so, let us assume that $x_{n}\to x_{0}$ implies that $f(x_{n})\to f(x_{0})$ but $f$ is not continuous at $x_{0}$.
Hence there exists a positive real number $\varepsilon > 0$ s.t. for every $\delta > 0$ there corresponds a $x_{\delta}\in X$ satisfying
\begin{align*}
d_{X}(x_{\delta},x_{0}) < \delta\quad\text{and}\quad d_{Y}(f(x_{\delta}),f(x_{0}))\geq \varepsilon
\end{align*}
In particular, for every $\delta = 1/n$ there corresponds a $x_{n}\in X$ s.t. $d_{X}(x_{n},x_{0}) < 1/n$.
Taking the limit, it results from the sandwich theorem that $x_{n}\to x_{0}$ but $d_{Y}(f(x_{n}),f(x_{0}))\geq \varepsilon > 0$, which contradicts our assumption. Therefore the original result holds and we are done.
Solution
Based on the previous discussion, let $(X,d_{X})$, $(Y,d_{Y})$ and $(Z,d_{Z})$ be metric spaces and $f:X\to Y$, $g:Y\to Z$ be continuous functions.
Let $x_{n}\in X$ be a sequence which converges to $x_{0}\in X$. Since $f$ is continuous, we conclude that $f(x_{n})\in Y$ converges to $f(x_{0})\in Y$. Moreover, due to the continuity of $g$, we conclude that $g(f(x_{n}))$ converges to $g(f(x_{0}))$.
In other words, we have just proven that the convergence of the sequence $x_{n}\in X$ to $x_{0}$ with respect to $d_{X}$ implies the convergence of the sequence $(g\circ f)(x_{n})$ with respect to $d_{Z}$, thence we conclude that $g\circ f:(X,d_{X})\to(Z,d_{Z})$ is continuous, and we are done.
BONUS
Based on this previous demonstration, you can prove continuity as follows:
\begin{align*}
\mathcal{O}\subseteq Z\,\,\text{is open} & \Rightarrow g^{-1}(\mathcal{O})\subseteq Y\,\,\text{is open}\\\\
& \Rightarrow f^{-1}(g^{-1}(\mathcal{O}))\subseteq X\,\,\text{is open}\\\\
& \Rightarrow (g\circ f)^{-1}(\mathcal{O})\subseteq X\,\,\text{is open}\\\\
& \Rightarrow g\circ f\,\,\text{is continuous}
\end{align*}
and we are done. Hopefully this helps.
