Why does the short exact sequence for projective module split? I want to understand the definition of surjective module in terms of splitting sequence. The definition says for a projective $R$-module $P$, the following short exact sequence $$0 \to A \xrightarrow{f} B \xrightarrow{g} P \to 0$$ splits, where $A,B$ are also $R$-modules.
I want to see why $B \cong A+P$ ?
The Wikipedia, says, then there is a section map $h:P \to B$ such that $gh=1_P$.

$(1)$ Why is so ?

This then says $B=\text{Im}(h)\oplus \text{ker}(g)$.

$(2)$ why is so ?

I am trying in the following way:
Since the given sequence is short exact sequence, the map $g$ is surjective. This means that $\text{Im}(g)=P$.
Now as $P$ is surjective module any module homomorphism factors through an epimorphism to $B$   i.e.,  for any $R$-module $C$  there exists an epimorphism (surjective module homomorphism) $i: C \twoheadrightarrow  B$ and a module homomorphism $j: P \to C$  such that $$ij=g.$$
I can't go further. What is the section map $h$ here ?
Any explanation of above two questions ?
 A: Consider the diagram:
\begin{align}
&P \\
&\Big\|\operatorname{id_P} \\[-3ex]
0\longrightarrow A\xrightarrow{\enspace f\enspace} B \xrightarrow{\enspace g\enspace}&P\longrightarrow 0
\end{align}
As $P$ is projective, and $g$ is onto, the map $\operatorname{id}_P$ factors through $B$, i.e. there exists a map $s:P\longrightarrow B$ such that  $g\circ s=\operatorname{id}_P$.
Some more details:
Any element $b\in B$ can be written as the sum of an element in $f(A)$ and an element in $s(P)$:
Indeed you easily check that $g\bigl(b-s(g(b))\bigr)=g(b)-(g\circ s)\bigl(g(b)\bigr)=g(b)-g(b)=0$, so there exists a (unique because $f$ is injective) $a$ such that
$$b-s\bigl(g(b)\bigr)=f(a)\iff b= f(a)+s\bigl(g(b)\bigr).$$
A: $\DeclareMathOperator{\im}{im}\DeclareMathOperator{\id}{id}$(2): Suppose $y = s(x) \in \im(s) \cap \ker(g)$. Then on the one hand $g(y) = 0$ and on the other hand $g(y) = g(s(x)) = \id_P(x) = x$ so $x = 0$. Therefore $\im(s) \cap \ker(g) = \{0\}$.
Next, suppose $y \in B$ and let $x = g(y)$, $z = s(x)$ and $z' = y - z$. Then

*

*$y = z + z'$

*$z \in \im(s)$

*$g(z') = g(y) - g(s(x)) = x - \id_P(x) = 0$ so $z' \in \ker(g)$
Thus $B = \im(s) \oplus \ker(g)$.
