In what follows there is an error. The problem is that I can't find it. Let $$0\longrightarrow L\overset{f}{\longrightarrow} M\overset{g}{\longrightarrow}N\longrightarrow 0$$ be a short exact sequence of $R$-modules and $R$-module homomorphisms. Then we have
$$M\cong\operatorname{Ker}g\oplus M/\operatorname{Ker}g$$ $$=\operatorname{Im}f\oplus M/\operatorname{Ker} g$$ $$\cong L\oplus g(M)$$ $$=L\oplus N$$
Your first line doesn't necessarily hold. Consider the short exact sequence of $\mathbb{Z}$-modules (abelian groups)
$$0\to\mathbb{Z}/2\mathbb{Z}\to\mathbb{Z}/4\mathbb{Z}\to\mathbb{Z}/2\mathbb{Z}\to 0$$
where the maps are the obvious ones. The issue is that not every submodule of $M$ necessarily has a complement.