[guided]To use maximality, we need a maximal partial extension. We apply Zorn's lemma to the poset $\mathcal{P}$. Zorn's lemma requires that every chain have an upper bound in the same poset.
Let $\mathcal{C}$ be a chain in $\mathcal{P}$. Its candidate upper domain is the union
\begin{align*}
C_* &:= \bigcup_{(C,g)\in \mathcal{C}} C.
\end{align*}
This is a left $R$-submodule of $B$: if $x,y\in C_*$, then $x\in C_1$ and $y\in C_2$ for some chain elements. Since $\mathcal{C}$ is linearly ordered, either $C_1\subset C_2$ or $C_2\subset C_1$, so both $x$ and $y$ lie in one common submodule. Therefore $x+y$ lies in that submodule, and for every $r\in R$, the element $rx$ lies in a chain submodule containing $x$. Also $A\subset C_*$ because every element of $\mathcal{P}$ contains $A$.
Now define the union map
\begin{align*}
g_*: C_* &\to I.
\end{align*}
For $x\in C_*$, choose a pair $(C,g)\in\mathcal{C}$ with $x\in C$, and put $g_*(x)=g(x)$. The point needing verification is well-definedness. If $x$ also lies in another domain $C'$, the chain condition says that either $(C,g)\leq(C',g')$ or $(C',g')\leq(C,g)$. In either case, the larger map restricts to the smaller one, so both maps assign the same value to $x$.
The same common-domain argument proves $R$-linearity. For $x,y\in C_*$ and $r\in R$, choose one chain element whose domain contains both $x$ and $y$. On that domain, the relevant partial extension is $R$-linear, so
\begin{align*}
g_*(x+y) &= g_*(x)+g_*(y), \\
g_*(rx) &= r g_*(x).
\end{align*}
Since each partial extension restricts to $f$ on $A$, the union map also satisfies $g_*|_A=f$. Thus $(C_*,g_*)$ is an upper bound for the chain. Zorn's lemma therefore gives a maximal partial extension $(M,h)$.[/guided]