This is a well known lemma that consistently appears in textbooks, either as a statement without proof, or as an exercise (see for example pp. 146 of Hatcher)
If $0 \stackrel{id}{\to} A \stackrel{f}{\to} B \stackrel{g}{\to} C\stackrel{h}{\to} 0$ is a short exact sequence of finitely generated abelian groups, then $\operatorname{rank} B = \operatorname{rank} A + \operatorname{rank} C$.
I've been trying to prove this unsuccessfully.
What do we know? $f$ is injective, $g$ is surjective, $\mathrm{Im} f = \mathrm{ker} g$, $\mathrm{Im} g = \mathrm{ker} h$, $C\simeq B/A$
So I start with a maximally linearly independent subset $\{ a_\alpha \}$ of $A$ such that the sum (with only finite non-zero entries) $$\sum n_\alpha a_\alpha=0$$ for $n_\alpha \in \mathbb{Z}$, implies that $n_\alpha=0$.
Where to go from here is a puzzle? Any hints would be appreciated
Pick a maximal linearly independent subset $\{c_{\beta}\}$ of $C$. Now push the $a_{\alpha}$ to $B$ using $f$, and for each $c_{\beta}$ pick $c'_{\beta}\in B$ such that $g(c'_{\beta}) = c_{\beta}$.
Now suppose that you have a finite linear combination of the $a_{\alpha}$ and the $c'_{\beta}$ that is equal to $0$, $$n_{\alpha_1}f(a_{\alpha_1}) + \cdots + n_{\alpha_k}f(a_{\alpha_k}) + m_{\beta_1}c'_{\beta_1} + \cdots + m_{\beta_{\ell}}c'_{\beta_{\ell}} = 0.$$ Use $g$ to get a conclusion about the $m_{\beta_j}$; then use $f$ to get a conclusion about the $n_{\alpha_i}$. This will give you that $\mathrm{rank}(B)\geq \mathrm{rank}(A)+\mathrm{rank}(C)$.
Do you also need help with the converse inequality?