For any two nonzero integers $m$ and $n$, we can construct an exact sequence $$ 0\to\mathbb{Z}/n\mathbb{Z}\to\mathbb{Z}/nm\mathbb{Z}\to\mathbb{Z}/m\mathbb{Z}\to 0 $$ where the first map sends $k+n\mathbb{Z}\to mk+nm\mathbb{Z}$, and the second map sends $k+nm\mathbb{Z}\to k+m\mathbb{Z}$.
My hunch is that the sequence is split iff $n$ and $m$ are relatively prime. I want to find an isomorphic sequence $$ 0\to\mathbb{Z}/n\mathbb{Z}\to\mathbb{Z}/n\mathbb{Z}\oplus\mathbb{Z}/m\mathbb{Z}\to\mathbb{Z}/m\mathbb{Z}\to 0 $$ If $f:\mathbb{Z}/nm\mathbb{Z}\to\mathbb{Z}/n\mathbb{Z}\oplus\mathbb{Z}/m\mathbb{Z}$ is to be an isomorphism, necessarily $n$ and $m$ are coprime. I wanted to define an isomorphism by $f(1+nm\mathbb{Z})=(1+n\mathbb{Z},1+m\mathbb{Z})$. However, the diagram of sequences doesn't commute, because going around the first square along the top I get $$ k+n\mathbb{Z}\to mk+nm\mathbb{Z}\to(mk+n\mathbb{Z},0+m\mathbb{Z}) $$ but going the other way the canonical embedding of $\mathbb{Z}/n\mathbb{Z}$ into the direct sum gives $$ k+n\mathbb{Z}\to k+n\mathbb{Z}\to (k+n\mathbb{Z},0+m\mathbb{Z}).$$
So the first coordinate is messing me up. Is my hunch wrong? Is there a more restrictive condition that $n$ and $m$ be coprime, but $n\mid m-1$ or something? I get this second condition by noticing $mk+n\mathbb{Z}=k+n\mathbb{Z}$ iff $n\mid (m-1)k$, and this must hold for all $k$, including $k=1$.
Let's look at possible substitutes for the isomorphism $f(1+nm\mathbb{Z})=(1+n\mathbb{Z},1+m\mathbb{Z})$. If, instead, we try $$f(1+nm\mathbb{Z})=(a+n\mathbb{Z},b+m\mathbb{Z}),$$ then for the left square to commute we need $ma\equiv 1\pmod n$, and for the right square to commute we just need $b\equiv 1\pmod m$.
So here we can select $b=1$, and the remaining question is, when does an integer $a$ exist such that $ma\equiv1\pmod n$. This is how the $\gcd$-condition enters the scene.
Remark: In the comments I suggested using CRT to construct splitting homomorphisms. When you want to produce a commutative diagram with given short exact sequences at the top and bottom, then the goal is to select the appropriate isomorphism in place of $f$. You can't just pick that isomorphism any which way you want, and expect to get a commutative diagram.