How can kernel of morphism in the category of abelian groups be treat as a functor I occurred into this kind of weird question when I was trying to formalize the result "the stalk of kernel is naturally isomorphic to the kernel of stalk" into a categorical statement, which I think should be a natural isomorphism between two functors.
For a simpler case, suppose we are working in the category $Ab$. Then taking the kernel of  $f: A \to B$ should return some map $g: C \to A$, supposing here we take the certain construction $C = \{x \in A| f(x) = 0\}$ and $g$ the inclusion. In this way taking the kernel  seems to be a functor from the arrow category to itself
$$
ker: Ab^{\rightarrow} \to Ab^{\rightarrow}
$$
Taking $f: A \to B$ to $i: kerf \to A$ (Here i reuse the operatorname "ker") and a morphism
$\require{AMScd}$
\begin{CD}
A @>{f}>> B\\
@VVV @VVV\\
C @>{g}>> D\\
\end{CD}
to
\begin{CD}
kerf @>{i}>> A\\
@VVV @VVV\\
kerg @>{j}>> C\\
\end{CD}
But this seems to be incorrect. Suppose we have another construction for the kernel $ker1 : Ab^{\rightarrow} \to Ab^{\rightarrow}$. The natural isomorphism between them I thought is:
\begin{CD}
kerf @>{i}>> A\\
@V{\eta}VV @V{\tau}VV\\
ker1(f) @>{i1}>> A\\
\end{CD}
But with this commute diagram, I cannot show that $i1 \circ \eta$ is still a kernel (i.e. satisfying the universal property), or that $\tau$ is the identity map, which I think should be true.
To maybe make my question clear and avoid the XY problem, the background of this question is that I want to formalize a natural isomorphism between two functors, which I think maybe was using the wrong category.

*

*the stalk of kernel functor: $Sh^{\rightarrow} \to Sh^{\rightarrow} \to Ab^{\rightarrow}$

*the kernel of stalk functor: $Sh^{\rightarrow} \to Ab^{\rightarrow} \to Ab^{\rightarrow}$
So is it a valid question? Can taking the kernel be treated as a functor between some categories, such that the natural transformation is identity in the original morphism square?
Thank you for any help!
 A: The key to viewing kernels as a functor is to get the domain category right.
Fix a pre-Abelian category $\mathcal{A}$. Then define $\mathcal{A}^{\cdot \to \cdot}$ to be the category where objects are triples $(A, B, f)$, where $A, B : \mathcal{A}$ and $f : A \to B$, and $Hom((A, B, f), (C, D, g)) = \{(h, i) \in Hom(A, C) \times Hom(B, D) \mid g \circ h = i \circ f\}$. Composition is pointwise.
Equivalently, $\mathcal{A}^{\cdot \to \cdot}$ can be viewed as the category of functors from a category $\cdot \to \cdot$ with 2 objects and 1 nontrivial arrow to $\mathcal{A}$.
In general, for any category $\mathcal{C}$ and any pre-Abelian category $\mathcal{A}$, the category $\mathcal{A}^\mathcal{C}$ is also pre-Abelian, with products, kernels, cokernels, and the addition operator done “pointwise”. If $\mathcal{A}$ is Abelian, so is $\mathcal{A}^\mathcal{C}$.
The kernel functor should be viewed as a functor $\ker : \mathcal{A}^{\cdot \to \cdot} \to A$. There is also a natural transformation $\ker \to dom$, where $dom(A, B, f) = A$. We abusively call this natural transformation $\ker$. The kernel functor and the kernel natural transformation together are unique up to unique isomorphism.
Now consider an additive functor $F : \mathcal{A} \to \mathcal{B}$ between pre-Abelian categories. We have an induced functor $F^{\cdot \to \cdot} : \mathcal{A}^{\cdot \to \cdot} \to \mathcal{B}^{\cdot \to \cdot}$ which is given by composition with $F$. To say that $F$ preserves kernels is to say that there is a natural isomorphism $\theta : F \ker \to \ker F^{\cdot \to \cdot}$ such that $dom F^{\cdot \to \cdot} \circ \theta = F dom$. This is analogous to the definition of “preserves products”, for instance.
Note that by the definition of $\ker$, we know there is a unique natural transformation $\theta : F \ker \to \ker F^{\cdot \to \cdot}$ such that $dom F^{\cdot \to \cdot} \circ \theta = F dom$. So it suffices to show that this particular $\theta$ is an isomorphism.
