We have the short exact sequence
$$
\newcommand{\im}{\operatorname{im}}
0
\longrightarrow \im(f)
\longrightarrow N
\xrightarrow{\enspace π \enspace} \mathrm{coker}(f)
\longrightarrow 0 \,.
$$
Let us assume for a moment that $\mathsf{C}$ is an exact, full subcategory of $\mathrm{Mod}_R$ for some ring $R$.
For every subobject $N'$ of $N$ we get the induced short exact sequence
$$
0
\longrightarrow \im(f) ∩ N'
\longrightarrow N'
\longrightarrow π(N')
\longrightarrow 0 \,.
$$
I will use two properties of multiplicities from my last post.
- Since $\im(f) ∩ N'$ is a subobject of $\im(f)$ we have $[\im(f) ∩ N' : S] ≤ [\im(f) : S] = 0$ and thus $[\im(f) ∩ N' : S] = 0$.
- By the additivity of multiplicities for short exact sequences, we have
$$
[N' : S]
= [\im(f) ∩ N' : S] + [π(N') : S]
= 0 + [π(N') : S]
= [π(N') : S] \,.
$$
Suppose now that $N' = \im(h)$ for some morphism $h \colon P \to N$.
Then
$$
π(N') = π(\im(h)) = \im(π ∘ h) \,,
$$
and so the equation $[N' : S] = [π(N') : S]$ becomes
$$
[\im(h) : S] = [\im(π ∘ h) : S] \,.
$$
For the required formulas we respectively choose $h = f + g$ and $h = g$.
For the case of a general abelian category $\mathsf{C}$ we have two choices.
We could use the Freyd–Mitchell embedding theorem to reduce the general case to the module case.
But we can also do the following:
Let $i \colon X \to Y$ be a subobject of $Y$ and let $f \colon Y \to Z$ be some morphism.
Define $f(X)$ as the image of the composite $f ∘ i$;
this image comes with an epimorphism $p \colon X \to f(X)$ and an inclusion morphism $j \colon f(X) \to Z$ such that $j ∘ p = f ∘ i$.
We claim that $\ker(f) ∩ X$ is the kernel of $p$.
Since $j$ is a monomorphism, both $p$ and $j ∘ p = f ∘ i$ have the same kernel;
so we want to show that $\ker(f) ∩ X$ is the kernel of $f ∘ i$.
For this, we consider the following diagram:
$$
\require{AMScd}
\begin{CD}
\ker(f) ∩ X @>>> \ker(f) @>>> 0 \\
@VVV @VVV @VVV \\
X @>>{i}> Y @>>{f}> Z
\end{CD}
$$
Both squares in this diagram are pullbacks, whence the overall diagram
$$
\require{AMScd}
\begin{CD}
\ker(f) ∩ X @>>> 0 \\
@VVV @VVV \\
X @>>{f ∘ i}> Z
\end{CD}
$$
is again a pullback.
This means that $\ker(f) ∩ X \to X$ is indeed the kernel of $f ∘ i$.
We have therefore the short exact sequence
$$
0
\longrightarrow \ker(f) ∩ X
\longrightarrow X
\xrightarrow{\enspace p \enspace} f(X)
\longrightarrow 0 \,.
$$
Given morphisms $f \colon X \to Y$ and $g \colon Y \to Z$, we want to show that $g( \im(f) ) = \im(g ∘ f)$.
We have an epimorphism $p \colon X \to \im(f)$ and the inclusion morphism $i \colon \im(f) \to X$ such that $f = i ∘ p$.
We have defined $g(\im(f))$ as the image of the composite $g ∘ i$, i.e., as the kernel of the cokernel of $g ∘ i$.
Similarly, $\im(g ∘ f)$ is the kernel of the cokernel of $g ∘ f$.
But both $g ∘ i$ and $g ∘ f$ have the same cokernel, since $g ∘ f = (g ∘ i) ∘ p$ with $p$ being an epimorphism.
Our argumentation now makes sense in any abelian category.