A sequence of $R$-modules of the form $$0 \to M_1 \stackrel{f}{\to} M \stackrel{g}{\to} M_2 \to 0$$ is called a short exact sequence (ses) if $f$ is injective, $g$ is surjective and $\operatorname{Im} f = \operatorname{Ker} g$.
A short exact sequence is said to split if there exist a $R$-homomorphism $h: M_2 \to M$ such that $g\circ h = \operatorname{Id}_{M_2}$.
It is well known that if a short exact sequence split then $M \cong M_1 \oplus M_2$.
What I am interested in is the converse. I know that the converse is not true. That is, there exist a short exact sequence with $M \cong M_1 \oplus M_2$ which does not split. I wish to construct such a counter example.
Consider $R=\mathbb{Z}$, $M_1=\mathbb{Z}/2\mathbb{Z}$ and $M'=\mathbb{Z}/4\mathbb{Z}$. Suppose we have a $\mathbb{Z}$-module $N$ such that $M_1\oplus N \cong N$ and $M' \oplus N \cong N$. Define $M= M'\oplus N$, and $M_2=M_1\oplus N$. Then $$M_1\oplus M_2 \cong M_1 \oplus N \cong N \cong M' \oplus N = M$$ Then consider the sequence $$0 \to M_1 \stackrel{f}{\to} M \stackrel{g}{\to} M_2 \to 0$$ where $f:M_1\to M=M''\oplus N$ is defined as $f(\bar{1})=(\bar{2},0)$ and $g: M \to M_2$ as $g(\bar{x},n)=(\bar{x},n)$. Then clearly $f$ is injective and $g$ is surjective and $\operatorname{Im} f = \operatorname{Ker} g$.
Suppose the ses splits. Then $h :M_2 \to M$ is such that $g\circ h =\operatorname{Id}_{M_2}$. But then $$h(\bar{1},0) \in g^{-1}(\bar{1},0)=\{\bar{1},0),(\bar{3},0)\}$$ But $2(\bar{1},0)=(\bar{2},0)$ and $2(\bar{3},0)=(\bar{2},0)$ in $M$. Thus $$h(\bar{0},0)=2h(\bar{1},0)=(\bar{2},0)$$ which contradicts the fact that $h$ is a homomorphism. Thus the ses does not splits.
The only thing that remains to show the existence of such an $N$. However, I am no able to show that such an $N$ does exists. Any help/ suggestions.