Let \(f,g,h\) be as stated. Then we know that
\begin{equation*}
g \circ f = i_A \qquad \text{ and } \qquad f \circ h = i_B
\end{equation*}
Now starting with \(g\) we can write:
\begin{align*}
g \amp = g \circ i_B \\
\amp = g \circ (f \circ h) = (g \circ f) \circ h\\
\amp = i_A \circ h = h
\end{align*}
and thus \(g=h\) as required.
The last part of the lemma follows by combining the previous two lemmas.