$f$ is injection:
Suppose $a, a' \in A$ and $f(a) = f(a')$. Applying $g$ to both side gives $g\circ f(a) = g\circ f(a')$. Since $g\circ f$ is injection, we conclude that $a = a'$. This shows that $f$ is injection. (Note that this is independent from the hypothesis that $f$ is surjection.)
$g$ is injection:
Suppose $b, b' \in B$ and $g(b) = g(b')$. Since $f$ in surjection, there exists $a, a' \in A$ such that $b = f(a)$ and $b' = f(a')$. Hence we get $g\circ f(a) = g(b) = g(b') = g\circ f(a')$. Since $g\circ f$ is injection, $a = a'$ follows. Applying $f$ to both side gives $b = f(a) = f(a') = b'$. This shows that $g$ in injection.
Edited: Your proof in the question is wrong. To show the injectivity of $h$, you have to show that
$$ h(x) = h(y) \implies x = y$$
as I did above or its contoraposition
$$ x \neq y \implies h(x) \neq h(y) $$
for all $x$ and $y$. So your proof should be
- Assume $b \neq b'$.
- There exists $a, a' \in A$ such that $b = f(a)$ and $b' = f(a')$ since $f$ is surjection.
- Hence $f(a) \neq f(a')$.
- $a \neq a'$. Otherwise $f(a) = f(a')$, contradiction.
- $g \circ f(a) \neq g \circ f(a')$ since $g \circ f$ is injection.
- Therefore $g(b) \neq g(b')$.
- Conclude $g$ is injection.
- Assume $a \neq a'$.
- $g \circ f(a) \neq g \circ f(a')$ since $g \circ f$ is injection.
- Hence $f(a) \neq f(a')$. Otherwise $g \circ f(a) = g \circ f(a')$, contradiction.
- Conclude $f$ is injection.