# Major confusion about sheaves of rings and sheaves of modules on schemes

So this question has largely grown out of two previous questions I asked:

Question about notation/conventions for localizations of R-algebras

I have identified and consolidated some of my major points of confusion.

Take exercise (2.18a) from Hartshorne as an example. There I am asked to show that if I have a morphism of rings $\phi: A \longrightarrow B$ with corresponding morphism of schemes $f: \text{Spec} B \longrightarrow \text{Spec}A$, then the corresponding morphism of sheaves $f^{\#}: \mathcal{O}_{Y} \longrightarrow f_{*}\mathcal{O}_{X}$ is injective if and only if $\phi$ is injective.

Let me first lay out what I understand before getting to what is confusing me. After doing section 2.1 of Hartshorne, I felt comfortable with sheaves taking values in an abelian category. Once I got to section 2.2, however, I got a little lost. The issue that everything is done in terms of sheaves of $\textit{rings}$, which certainly do not form an abelian category (indeed we don't even have kernels!). When we take stalks of these sheaves, we find that at some point $p$ (say a prime ideal of $B$), the stalk of the sheaf $\mathcal{O}_{X}$ at $p$ is the local $\textit{ring}$ $A_{p}$. This was all well and good until I came to trying to apply exactness results for localization.

Returning to the exercise I mentioned above, I went about showing that the sheaf is injective on sections. I started with $\phi: A \longrightarrow B$ and localized at a basic open set $D(h)$ to consider the morphism $$A_{h} \longrightarrow B_{\phi(h)}$$ I then thought I could just say that since localization is exact, this preserves exactness. However, I realized that this exactness result only holds for modules. That is, if I treated $B$ as a module over $A$, then it would be perfectly fine for me to claim that the map of $\textit{modules}$ $$A_{h} \longrightarrow B_{h} \simeq A_{h} \otimes _{A} B$$ is injective. Speaking more generally than just the exericse, what exactly can I say about morphisms of sections, and induced morphisms of stalks since they are rings, not modules. It seems like all of section 2.1 was useless.

I have also been looking at the notion of base change where I hit a similar problem. Say the morphism $\phi: A \longrightarrow B$ makes $B$ into a finite-type $A$-algebra. We would like to claim that finite-type morphisms of schemes are preserved under base change. That is, we would like to be able to say that via base change, the morphism $$A_{h} \longrightarrow B_{\phi(h)}$$ makes $B_{\phi(h)}$ into a finite-type $A_{h}$-algebra. I can do this the hands-on way by showing how finitely many generators of $B$ over $A$ map under localization, but I wanted to try to see this more abstractly. I wanted to see the localization $B_{\phi(h)}$ as the pushout of the diagram

which would be the tensor product $A_{h} \otimes_{A} B$. Then I realized again that this would only be the case in the category of modules, which brought me back to my original confusion. Is it true that as rings, there holds $B_{\phi(h)} \simeq A_{h} \otimes_{A} B$? Or is it only true when we treat $A$ and $B$ as $\textit{modules}$ that $B_{h} \simeq A_{h} \otimes_{A} B$, in which case we could apply exactness results?

I'm sorry for the long post, but this is really bugging me and I wanted to lay out as much detail as I could. I'm still not entirely sure I have asked the question exactly the right way, but I am hoping people can still clear up any confusion.

A ring map $\varphi:A\to B$ endows $B$ with the structure of an $A$-module, and for this structure and the canonical $A$-module structure on $A$ itself, this is a map of $A$-modules. Injectivity has nothing to do with the ring structures, only the abelian group structures. So if $\varphi:A\to B$ is injective, you can still apply the exactness of localization to deduce that, for any multiplicative subset $S$ of $A$, $S^{-1}\varphi:S^{-1}A\to S^{-1}B$ is again injective (this is actually a map of rings, but that is irrelevant in considering its injectivity).
If this reasoning bothers you, it's not hard to verify the assertion directly. Using the usual description of elements in localizations, the map $S^{-1}\varphi$ sends $a/s$ to $\varphi(a)/s$. Suppose this is zero in $S^{-1}B$. That means, by definition, that there is $t\in S$ for which $0=\varphi(t)\varphi(a)=\varphi(ta)$. Since $\varphi$ is injective, $ta=0$, and this means (again, by definition) that $a/s=0$ in $S^{-1}A$.
Your second concern is addressed by the following result. If $M$ is any $B$-module (so $M$ is also an $A$-module via $\varphi$) and $S$ is a multiplicative subset of $A$, then $T=\varphi(S)$ is a multiplicative subset of $B$, and there is a canonical isomorphism $S^{-1}M\simeq T^{-1}M$ given by $m/s\mapsto m/\varphi(s)$. When $M=B$, the isomorphism $S^{-1}B\simeq T^{-1}B$ is an isomorphism of $S^{-1}A$-algebras. But in particular it is still an isomorphism of $S^{-1}A$-modules. So again you can apply results about localizations of modules. Or, alternatively, as above, you could reason directly.