Why doesn't the localization map $A \to A_f$ show that open embeddings of schemes are not always monomorphisms? Suppose $\iota: X \hookrightarrow Y$ is an open embedding of schemes. We can assume $X$ is an open subscheme of $Y$.
On the level of sets, $\iota$ is injective.
I wish to see that the pullback map $\iota^\sharp: \mathcal O_Y \to \mathcal O_Y|_X$ is injective.
I don't see how this is always true.
For example, if we take a ring $A$ which is not a domain, then the localization (restriction) map $A \to A_f$ is not always injective.
Doesn't this show that open embedding are not always monomorphisms?
If not, where is the error?
 A: Let's recap the discussion from the comments and provide a full solution to the problem.
First, we'll fix the definition of an open immersion: a map $f:X\to Y$ is an open immersion of locally ringed spaces if and only if $f$ is a homeomorphism of $X$ on to an open subset of $Y$ and the pullback map $f^{-1}\mathcal{O}_Y\to \mathcal{O}_X$ is an isomorphism (ref 01HE). This is the standard way to talk about "the pullback morphism", and I'm emphasizing it because you apply the adjunction between $(-)^{-1}$ and $(-)_*$ to write it a different way, where the map is no longer an isomorphism but instead an isomorphism over the image of $f$ and zero elsewhere.
Next, we'll address your confusion about $A\to A_f$. In order to verify that the stalks of $\mathcal{O}_{\operatorname{Spec} A}$ and $\mathcal{O}_{\operatorname{Spec} A_f}$ are the same for all points in $\operatorname{Spec} A_f$, let's remember what those points are. There is a bijection between prime ideals of $A_f$ and prime ideals of $A$ not meeting $f$, so suppose we have a prime ideal $\mathfrak{p}\subset A$ not meeting $f$ which gives a prime ideal $\mathfrak{p}_f\subset A_f$. Then the stalk of $\mathcal{O}_{\operatorname{Spec} A}$ at $\mathfrak{p}$ is $A_\mathfrak{p}$, while the stalk of $\mathcal{O}_{\operatorname{Spec} A_f}$ at $\mathfrak{p}_f$ is $(A_f)_{\mathfrak{p}_f}$. But since localization is transitive and $f\notin \mathfrak{p}$ by assumption, $(A_f)_{\mathfrak{p}_f}\cong A_\mathfrak{p}$ and the stalks are the same as requested.
A: I deleted my previous answer, as it seemed it didn't truly address the question. Nevertheless, I think there are some facts related to open immersions and monomorphisms that seem relevant to this situation.
In this stacks article you'll find that a morphism of $X \to Y$ of schemes is a monomorphism if and only if the diagonal morphism
$$X \longrightarrow X \times_Y X$$
is an isomorphism. Heuristically, this is saying that a morphism is a monomorphism if and only if the self-intersection of the image is the image itself. Put in this way, it should be at least intuitively clear that an open immersion is a monomorphism.
If we restrict to the category $\mathbf{Aff}$ of affine schemes, the condition that $X \to Y$ is a monomorphism may be rephrased slightly differently. Recall that there is an equivalence of categories
$$\mathbf{Rings}^{op} \longrightarrow \mathbf{Aff}$$
given by associating to a commutative unital ring its spectrum. It follows that a monomorphism $\operatorname{Spec}(B) \longrightarrow \operatorname{Spec}(A)$
in the category of affine schemes corresponds to an $\textit{epimorphism}$
$A \longrightarrow B$ in the category of commutative unital rings. It is therefore a fact (and exercise) that any localization $A \to S^{-1}A$ is an epimorphism in $\mathbf{Rings}$.
Just a word of clarification in case it's not obvious already: while all monomorphisms of rings are injections, it is not true that all epimorphisms of rings are surjections.
