$\textbf{Statement.}$ Let $f : X \rightarrow Y$ and $g : Y \rightarrow Z$ be functions. Assume $f$ and $g$ are onto. Then $g \circ f : X \rightarrow Z$ is onto.
$\textbf{Proof.}$ Let $(g \circ f)(x) \in Z$. Then $(g \circ f)(x) = z$ for some $z \in Z$. Since $x \in X$, and $(g \circ f)(x) = z$, we conclude that $g \circ f$ is onto.
Is this a valid proof that $g \circ f$ is onto? Why or why not?
Your proof is not valid as you are assuming what you want to prove, i.e. the existence of such an $x$.
Take $z \in Z$, you want to show that $\exists x \in X. (g \circ f)(x)=z.$
$$g \text{ onto } \implies \exists y \in Y. g(y) = z.$$
$$f\text{ onto }\implies \exists x \in X. f(x) = y.$$
$$\implies \exists x \in X. (g \circ f)(x)=g(f(x))=g(y)=z.$$