[proofplan]
The implications $(1) \implies (2) \implies (3)$ follow from the exactness of localization and the fact that every maximal ideal is prime. For $(3) \implies (1)$, we reduce both injectivity and surjectivity to the statement that a certain module is zero, then apply the fact that being zero is a local property ([Being Zero Is a Local Property](/theorems/2852)). For injectivity, the relevant module is $\ker f$; for surjectivity, it is $\operatorname{coker} f = N / \operatorname{im} f$. Localization commutes with kernels and cokernels because it is an exact functor, so the local vanishing hypotheses translate directly.
[/proofplan]
[step:Verify $(1) \implies (2)$: localization preserves injectivity and surjectivity]
Localization is an exact functor: if $0 \to A \xrightarrow{g} B \xrightarrow{h} C \to 0$ is an exact sequence of $R$-modules, then for any multiplicative subset $S \subseteq R$, the sequence $0 \to S^{-1}A \xrightarrow{S^{-1}g} S^{-1}B \xrightarrow{S^{-1}h} S^{-1}C \to 0$ is exact.
Applying this to $f: M \to N$: if $f$ is injective, the sequence $0 \to M \xrightarrow{f} N$ is exact, and localizing at $\mathfrak{p}$ gives the exact sequence $0 \to M_\mathfrak{p} \xrightarrow{f_\mathfrak{p}} N_\mathfrak{p}$, so $f_\mathfrak{p}$ is injective. If $f$ is surjective, the sequence $M \xrightarrow{f} N \to 0$ is exact, and localizing gives $M_\mathfrak{p} \xrightarrow{f_\mathfrak{p}} N_\mathfrak{p} \to 0$, so $f_\mathfrak{p}$ is surjective.
[/step]
[step:Verify $(2) \implies (3)$: maximal ideals are prime]
Every maximal ideal is prime, so $\operatorname{mSpec}(R) \subseteq \operatorname{Spec}(R)$. If $f_\mathfrak{p}$ is injective (resp. surjective) for all $\mathfrak{p} \in \operatorname{Spec}(R)$, then in particular $f_\mathfrak{m}$ is injective (resp. surjective) for all maximal ideals $\mathfrak{m}$.
[/step]
[step:Prove $(3) \implies (1)$ for injectivity: reduce to $\ker f = 0$ via localness of being zero]
Consider the exact sequence
\begin{align*}
0 \to \ker f \to M \xrightarrow{f} N.
\end{align*}
Localizing at a maximal ideal $\mathfrak{m}$ preserves exactness, giving
\begin{align*}
0 \to (\ker f)_\mathfrak{m} \to M_\mathfrak{m} \xrightarrow{f_\mathfrak{m}} N_\mathfrak{m}.
\end{align*}
Exactness at $M_\mathfrak{m}$ gives $(\ker f)_\mathfrak{m} = \ker(f_\mathfrak{m})$. By hypothesis, $f_\mathfrak{m}$ is injective for every maximal ideal $\mathfrak{m}$, so $\ker(f_\mathfrak{m}) = 0$, and hence $(\ker f)_\mathfrak{m} = 0$ for every maximal ideal $\mathfrak{m}$.
By [Being Zero Is a Local Property](/theorems/2852) (the implication $(3) \implies (1)$), $\ker f = 0$, so $f$ is injective.
[guided]
We want to show that if $f_\mathfrak{m}$ is injective for every maximal $\mathfrak{m}$, then $f$ is injective. The strategy is to show $\ker f = 0$ by checking it locally.
The sequence $0 \to \ker f \hookrightarrow M \xrightarrow{f} N$ is exact by definition of the kernel. Localization is exact, so localizing at $\mathfrak{m}$ gives the exact sequence
\begin{align*}
0 \to (\ker f)_\mathfrak{m} \to M_\mathfrak{m} \xrightarrow{f_\mathfrak{m}} N_\mathfrak{m}.
\end{align*}
Exactness at $M_\mathfrak{m}$ means the kernel of $f_\mathfrak{m}$ equals the image of the map $(\ker f)_\mathfrak{m} \to M_\mathfrak{m}$, so $(\ker f)_\mathfrak{m} \cong \ker(f_\mathfrak{m})$.
Since $f_\mathfrak{m}$ is injective by hypothesis, $\ker(f_\mathfrak{m}) = 0$, giving $(\ker f)_\mathfrak{m} = 0$.
This holds for every maximal ideal $\mathfrak{m}$, so by [Being Zero Is a Local Property](/theorems/2852), $\ker f = 0$. Hence $f$ is injective.
The key point is the interplay between two localness results: exactness of localization lets us compute $(\ker f)_\mathfrak{m}$ as $\ker(f_\mathfrak{m})$, and then the fact that being zero is a local property upgrades the local vanishing to global vanishing.
[/guided]
[/step]
[step:Prove $(3) \implies (1)$ for surjectivity: reduce to $\operatorname{coker} f = 0$ via localness of being zero]
Define the cokernel $\operatorname{coker} f = N / \operatorname{im} f$. The sequence
\begin{align*}
M \xrightarrow{f} N \to \operatorname{coker} f \to 0
\end{align*}
is exact. Localizing at $\mathfrak{m}$ gives the exact sequence
\begin{align*}
M_\mathfrak{m} \xrightarrow{f_\mathfrak{m}} N_\mathfrak{m} \to (\operatorname{coker} f)_\mathfrak{m} \to 0.
\end{align*}
Exactness at $N_\mathfrak{m}$ identifies $(\operatorname{coker} f)_\mathfrak{m} \cong N_\mathfrak{m} / \operatorname{im}(f_\mathfrak{m}) = \operatorname{coker}(f_\mathfrak{m})$. By hypothesis, $f_\mathfrak{m}$ is surjective for every maximal ideal $\mathfrak{m}$, so $\operatorname{coker}(f_\mathfrak{m}) = 0$, and hence $(\operatorname{coker} f)_\mathfrak{m} = 0$ for every maximal ideal $\mathfrak{m}$.
By [Being Zero Is a Local Property](/theorems/2852), $\operatorname{coker} f = 0$, which means $\operatorname{im} f = N$, so $f$ is surjective.
[guided]
The surjectivity argument is completely parallel to the injectivity argument, with the kernel replaced by the cokernel.
Define $\operatorname{coker} f = N / \operatorname{im} f$. The surjectivity of $f$ is equivalent to $\operatorname{coker} f = 0$. The exact sequence $M \xrightarrow{f} N \to \operatorname{coker} f \to 0$ localizes to
\begin{align*}
M_\mathfrak{m} \xrightarrow{f_\mathfrak{m}} N_\mathfrak{m} \to (\operatorname{coker} f)_\mathfrak{m} \to 0.
\end{align*}
By exactness at $N_\mathfrak{m}$, the image of $(\operatorname{coker} f)_\mathfrak{m} \to 0$ is $0$, and the kernel of the map $N_\mathfrak{m} \to (\operatorname{coker} f)_\mathfrak{m}$ equals $\operatorname{im}(f_\mathfrak{m})$. This gives $(\operatorname{coker} f)_\mathfrak{m} \cong N_\mathfrak{m} / \operatorname{im}(f_\mathfrak{m}) = \operatorname{coker}(f_\mathfrak{m})$.
Since $f_\mathfrak{m}$ is surjective for every maximal $\mathfrak{m}$ by hypothesis, $\operatorname{coker}(f_\mathfrak{m}) = 0$, so $(\operatorname{coker} f)_\mathfrak{m} = 0$ for all maximal $\mathfrak{m}$. By [Being Zero Is a Local Property](/theorems/2852), $\operatorname{coker} f = 0$, i.e., $f$ is surjective.
The pattern for both directions is the same: express the property ($f$ injective / $f$ surjective) as the vanishing of a module ($\ker f$ / $\operatorname{coker} f$), use exactness of localization to identify the localization of that module with the corresponding object for $f_\mathfrak{m}$, and apply localness of being zero.
[/guided]
[/step]