Isomorphism theorem for Abelian groups, related to Hatcher exercise 2.1.14 I am trying to understand which Abelian groups can fit the short exact sequence 
\begin{equation}
0 \rightarrow \mathbb{Z}_{p ^m}\rightarrow A \rightarrow \mathbb{Z}_{p^n}\rightarrow 0.
\end{equation}
If I would be dealing with vector spaces (or free Abelian groups) then I would say that $A \sim \mathbb{Z}_{p ^m}\oplus \mathbb{Z}_{p^n} $ which uniquely determines $A$ by the classification of finitely generated Abelian groups. However I am told that $A\sim \mathbb{Z}_{p^k}\oplus\mathbb{Z}_{p^{m+n-k}}$ with $0\leq k\leq \mathrm{min}\{m,n\}$. 
I imagine the difference with my expected answer has to do with the difference between how the isomorphism theorem applies in the case of free Abelian groups and not free ones.
Could anyone list/explain the main differences one encounters in passing from the free Abelian groups case and not free one and, if it is not too different, between the case of free modules and generic modules? (I am happy to restrict the discussion with finitely generated modules). I do not need a detailed analysis, but more of a bird-eye view of the differences between the two setups that one should keep in mind, especially in relation with the problem above.
 A: The reason that you cannot conclude that $A$ is a direct sum of its neighboring terms is because not every short exact sequence splits. (A short exact sequence splits iff the quotient map admits a right inverse.) If the final nonzero term in a short exact sequence is free (or more generally projective), then it will split. For example a $k$-vector space is a free $k$-module since it has a basis, hence any short exact sequence of vector spaces splits. But $\mathbb{Z}_{p^n}$ is not a free $\mathbb{Z}$-module.

For the problem at hand, first note that $A$ is an abelian group of order $p^{m+n}$ generated by two elements (the image of 1 under $\mathbb{Z}_{p^m} \to A$, and a preimage of 1 under $A\to\mathbb{Z}_{p^n}$). Thus $A$ has the form
$$ A \cong \mathbb{Z}_{p^k} \oplus \mathbb{Z}_{p^{m+n-k}}, $$
where without loss of generality $k\leq m+n-k$. So we just need to show also that $k\leq\min(m,n)$.
To do this, we can apply the $\mathrm{Hom}(\mathbb{Z}_{p^\ell},-)$ functor. This is a left exact functor from the category of abelian groups to abelian groups, meaning that if $0\to K\to L\to M\to 0$ is a short exact sequence of abelian groups, then
$$ 0 \to \mathrm{Hom}(\mathbb{Z}_{p^\ell}, K) \to \mathrm{Hom}(\mathbb{Z}_{p^\ell}, L) \to \mathrm{Hom}(\mathbb{Z}_{p^\ell}, M) $$
is an exact sequence of abelian groups. Note the missing zero on the right! This is because the functor is only left exact, not exact. This functor is also additive, i.e. it preserves direct sums.
We will also need that $\mathrm{Hom}(\mathbb{Z}_{p^i}, \mathbb{Z}_{p^j}) \cong \mathbb{Z}_{p^{\min(i,j)}}$. To see this note that a homomorphism $\mathbb{Z}_{p^i} \to \mathbb{Z}_{p^j}$ is completely determined by the image of 1, which can be sent to any element of $\mathbb{Z}_{p^j}$ whose order divides $p^i$. The hom set is thus a cyclic group of order $p^{\min(i,j)}$ generated by the homomorphism defined by $1\mapsto p^{j-\min(i,j)}$.
Applying $\mathrm{Hom}(\mathbb{Z}_{p^\ell},-)$ to the short exact sequence $0\to\mathbb{Z}_{p^m}\to\mathbb{Z}_{p^k}\oplus\mathbb{Z}_{p^{m+n-k}}\to\mathbb{Z}_{p^n}\to0$ gives the exact sequence
$$ 0 \to \mathbb{Z}_{p^{\min(\ell,m)}} \to \mathbb{Z}_{p^{\min(\ell,k)}} \oplus \mathbb{Z}_{p^{\min(\ell,m+n-k)}} \to \mathbb{Z}_{p^{\min(\ell,n)}}. $$
If there were a "$\to0$" on the right making this short exact, then the middle term would have order equal to the product of the two terms surrounding it. However, since the final map above need not be surjective, we instead get an inequality on the orders. Thus
$$ \min(\ell,k) + \min(\ell,m+n-k) \leq \min(\ell,m) + \min(\ell,n). $$
This needs to hold for all $\ell$, in particular when $\ell=\min(m,n)+1$. If $k>\min(m,n)$, then for this $\ell$ the left side is $2\ell$, whereas the right side is at most $2\ell-1$, contradiction. Hence $k\leq\min(m,n)$.

Finally you want to show that these $A$ are all possible, for this note that if $k\leq\min(m,n)$ then
$$  0 \to \mathbb{Z}_{p^m} \xrightarrow{1 \mapsto (1, p^{n-k})} \mathbb{Z}_{p^k} \oplus \mathbb{Z}_{p^{m+n-k}} \xrightarrow{\quad\substack{(1,0)\mapsto -p^{n-k}\\(0,1)\mapsto 1\phantom{---}}} \mathbb{Z}_{p^n} \to 0 $$
is a short exact sequence. (Can you see why both $k\leq m$ and $k\leq n$ are required here?)
