I prefer summerize and improve the answers of Qiaochu Yuan and basket!
Let $A$ and $B$ be rings, $X=\operatorname{Spec}A$ and $Y=\operatorname{Spec}B$; one can prove that the function
$$
\Phi:(f,f^{\sharp})\in\operatorname{Hom}_{\bf LocRingSp}((X,\mathcal{O}_X),(Y,\mathcal{O}_Y))\to f^{\sharp}(Y)\in\operatorname{Hom}_{\bf Ring}(B,A)
$$
is bijective; moreover, the morphism $(f,f^{\sharp})$ is uniquely determined by $f^{\sharp}(Y)$.
What I mean? Which is the improvement?
As you (user306194) affirm: given a morphism of rings (that is $f^{\sharp}(Y)$ in my notation) you can construct a unique morphism of locally ringed spaces $(f,f^{\sharp})$; but, given a continuous map $f$ between the support of locally ringed spaces, you can't define uniquely $f^{\sharp}$!
For example: you read the previous comment of Hoot.
Obviously, all this works in the setting of schemes.
In general, let $A$ be a ring and let $Y$ be a scheme, $X=\operatorname{Spec}A$; one can prove that the function
$$
\Phi:(f,f^{\sharp})\in\operatorname{Hom}_{\bf Sch}(Y,X)\to f^{\sharp}(X)\in\operatorname{Hom}_{\bf Ring}(A,\mathcal{O}_Y(Y))
$$
is bijective.
Moreover in general: let $S$ be a scheme, let $X$ be an $S$-scheme with structure morphism $p$ and let $\mathcal{A}$ be a quasi-coherent $\mathcal{O}_S$-algebra; one can prove that the function
$$
\Phi:(f,f^{\sharp})\in\operatorname{Hom}_{S-\bf Sch}(X,\operatorname{Spec}\mathcal{A})\to f^{\sharp}(\operatorname{Spec}\mathcal{A})\in\operatorname{Hom}_{\mathcal{O}_S-\bf Alg}(\mathcal{A},p_{*}\mathcal{O}_X)
$$
is bijective; where $\operatorname{Spec}\mathcal{A}$ is the relative spectrum of $\mathcal{A}$.
For a reference, I council Bosch - Commutative Algebra and Algebraic geometry, Springer, sections 6.6 and 7.1.
In conclusion, I remember you that $\operatorname{Spec}(A\otimes_{\mathbb{C}}B)$ is canonically isomorphic to $\operatorname{Spec}A\times_{\operatorname{Spec}\mathbb{C}}\operatorname{Spec}B$; usually, the Cartesian product of sets is very bad in the category of schemes.
From the same book, I council you the section 7.2 with any examples and exercises 3, 4 and 5.
You can observe that
$O_X(X)\cong A$
where $O_X(X)$ is the Space of the global section of $X$.
Then if you have a morphism of scheme
$(f,f^*): (X,O_X)\to (Y, O_Y)$
you get a morphism
$f^*(A): O_X(X)\cong A\to (f_*O_Y)(A)\cong B$
This is the unique morphism which induces exactly $(f,f^*)$.
In fact if $\phi: A\to B$ is a morphism of ring which induces $(f,f^*)$, then for each $a\in A$, if we denote with $a^\sim\in O_X(X)$ the global constant section of $a$, we get
$f^*(a^\sim)=\phi(a)^\sim$
so, up to isomorphism of $O_X(X)\cong A$, one get
$f^*(a)=\phi(a)$
Best Answer
You are correct, the direct limit $\varinjlim\mathcal{O}_X(f^{-1}(V))$ is essentially given by $A\otimes_B B_{\phi^{-1}(P)}$ (once you shrink to affine opens containing $P$ and $f(P)$). Here's a proof.
First, observe that when $X$ and $Y$ are schemes, it suffices to understand the affine case. Choose an affine open neighborhood $\operatorname{Spec}(B)\subseteq Y$ of $f(P)$ and an affine open neighborhood $\operatorname{Spec}(A)\subseteq X$ of $P$ with $\operatorname{Spec}(A)\subseteq f^{-1}(\operatorname{Spec}(B)).$ Then we have $\mathcal{O}_{X,P} = \mathcal{O}_{\operatorname{Spec}(A),P}$ and $\mathcal{O}_{Y,f(P)} = \mathcal{O}_{\operatorname{Spec}(B),f(P)}.$
So, let us assume that $X = \operatorname{Spec}(A)$ and $Y = \operatorname{Spec}(B),$ and that $f : X\to Y$ comes from the morphism $\phi : B\to A$ of rings. Let $\mathfrak{p}\subseteq A$ be the prime ideal of $A$ corresponding to the point $P\in X,$ and let $\mathfrak{q} = \phi^{-1}(\mathfrak{p})$ be the prime ideal of $B$ corresponding to $f(P).$ Since distinguished opens $D(b)$ with $b\in B$ form a basis for the Zariski topology on $Y,$ we may compute the direct limit defining the stalk as \begin{align*} \varinjlim_{D(b)\ni f(P)} \mathcal{O}_{\operatorname{Spec}(B)}(D(b)) &\cong \varinjlim_{b\not\in\mathfrak{q}} B[b^{-1}]\\ &\cong B_\mathfrak{q}. \end{align*}
Now, the direct limit we want to compute is $$ \varinjlim_{D(b)\ni f(P)}\mathcal{O}_{\operatorname{Spec}(A)}(f^{-1}(D(b))). $$ We have $f^{-1}(D(b)) = D(\phi(b)),$ so this simplifies as \begin{align*} \varinjlim_{D(b)\ni f(P)}\mathcal{O}_{\operatorname{Spec}(A)}(f^{-1}(D(b))) &= \varinjlim_{b\not\in\mathfrak{q}}\mathcal{O}_{\operatorname{Spec}(A)}(D(\phi(b)))\\ &\cong \varinjlim_{b\not\in\mathfrak{q}} A[\phi(b)^{-1}]. \end{align*}
Putting all this together using the fact that the tensor product commutes with colimits, it follows that \begin{align*} A\otimes_B B_\mathfrak{q} &\cong A\otimes_B \varinjlim_{b\not\in\mathfrak{q}} B[b^{-1}]\\ &\cong \varinjlim_{b\not\in\mathfrak{q}}\left(A\otimes_B B[b^{-1}]\right)\\ &\cong \varinjlim_{b\not\in\mathfrak{q}}A[\phi(b)^{-1}]\\ &\cong \varinjlim_{D(b)\ni f(P)}\mathcal{O}_{\operatorname{Spec}(A)}(f^{-1}(D(b))). \end{align*}
EDIT: As requested, we shall prove that the localization of a ring can be interpreted as a suitable colimit.
Let $A$ be a commutative ring, and let $S\subseteq A$ be a multiplicative set. Consider $S$ as a category whose objects are elements of $S,$ and whose hom-sets are given by $$ \operatorname{Hom}_S(s,t) = \begin{cases}\ast,\qquad\textrm{if there exists }u\in A\textrm{ such that }t = su,\\ \emptyset,\qquad\textrm{otherwise}. \end{cases} $$ Then we may define a functor from $S$ to the category of commutative rings (or even commutative $A$-algebras, if you want) by \begin{align*} F : S&\to\mathsf{CRing}\\ s&\mapsto A[s^{-1}]\\ (s\to t)&\mapsto\left(A[s^{-1}]\to A[t^{-1}]\right). \end{align*} The map $A[s^{-1}]\to A[t^{-1}]$ is simply further localization: $A[t^{-1}]\cong (A[s^{-1}])[u^{-1}].$
Now, we want to show that the colimit of the diagram defined by this functor is the localization $S^{-1}A.$ That is, we want to show
Lemma: With notation as above, $$\varinjlim_{s\in S} A[s^{-1}]\cong S^{-1} A.$$
Proof: We need to check that the colimit in question has the correct universal property; i.e., we must prove that given any morphism of rings $f : A\to T$ such that every element of $S$ is sent to a unit in $T,$ that we have a unique factorization of $f$ as $A\to \varinjlim_{s\in S} A[s^{-1}]\xrightarrow{f_S} T,$ where the first map is the canonical map.
By the universal property of localization, we find that for each $s\in S,$ $f$ factors uniquely as $A\to A[s^{-1}]\xrightarrow{f_s} T.$ Moreover, if $t\in S$ and $t = su,$ then we find that $f_t$ and $f_s$ are compatible in the sense that the composition $$ A[s^{-1}]\xrightarrow{\textrm{can}} A[t^{-1}]\xrightarrow{f_t} T $$ is simply $f_s.$
To see why the above is true, observe that $A[t^{-1}]$ is a localization of $A[s^{-1}]$ and $t\in A[s^{-1}]$ is sent to a unit in $T$ via $f_s,$ so there is a unique map $g : A[t^{-1}]\to T$ such that $f_s : A[s^{-1}]\to T$ factors through $g$ as $$A[s^{-1}]\xrightarrow{\textrm{can}}A[t^{-1}]\xrightarrow{g} T.$$ However, the composition $A\to A[s^{-1}]\xrightarrow{f_s} T$ is $f : A\to T,$ and the composition $A\to A[s^{-1}]\xrightarrow{\textrm{can}} A[t^{-1}]$ is simply the localization away from $t.$ Thus we see that $g$ satisfies the same property that $f_t$ does, and so uniqueness implies that $g = f_t.$
However, this compatibility between the various $f_s$ is precisely what is needed to obtain the map $\varinjlim_{s\in S} A[s^{-1}]\to T$ -- the universal property of a colimit now gives us a unique map $f_S : \varinjlim_{s\in S} A[s^{-1}]\to T$ factoring our given $f : A\to T,$ which is precisely what we needed. $\square$