$\DeclareMathOperator{\Spec}{Spec}
\def\O{\mathcal{O}}
\def\F{\mathcal{F}}
\DeclareMathOperator{\Hom}{Hom}
\def\G{\mathcal{G}}
\def\p{\mathrm{p}}
\DeclareMathOperator{\Mod}{Mod}$Let's give geometric motivation to the definition of the pullback of a section. Suppose $f:X\to Y$ is a morphism of topological manifolds (resp., of smooth manifolds, complex manifolds, or classical algebraic $k$-varieties), where $X$ and $Y$ are regarded as locally ringed spaces with their natural sheaves of real-valued continuous (resp., real-valued smooth, complex-valued holomorphic, $k$-valued regular) functions. Let $U\subset Y$ be open. The pullback of a section $s\in\mathcal{O}_Y(U)$ is defined to be $f^*s=s\circ f|_{f^{-1}(U)}\in\mathcal{O}_X(f^{-1}(U))$. That is, $f^*s$ is the image of $s$ along the map $f^\sharp:\mathcal{O}_Y\to f_*\mathcal{O}_X$. In general:
Definition 1
- Let $f:X\to Y$ be a continuous map of topological spaces, let $G$ a sheaf of sets over $Y$ and let $U\subset Y$ be open.
The inverse image of a section $s\in G(U)$, denoted $f^{-1}s$, is the image of $s$ along the unit $G\to f_*f^{-1}G$ of $f^{-1}\dashv f_*$.
- [GW, eq. (7.8.11), p. 184]. Let $f:X\to Y$ be a morphism of ringed spaces, let $G$ be a sheaf of $\mathcal{O}_Y$-modules and let $U\subset Y$ be open. The pullback of a section $s\in G(U)$, denoted $f^*s$, is the image of $s$ along the unit $G\to f_*f^*G$ of $f^*\dashv f_*$.
From the description of the unit of $f^*\dashv f_*$ as a composite at the end of Alex Kruckman's answer, it follows that $f^*s=f^{-1}s\otimes 1$, where the latter means the image of $f^{-1}s\otimes 1$ under the sheafification map
$\mathcal{O}_X\otimes_{\mathrm{p},f^{-1}\mathcal{O}_Y}f^{-1}G
\to
\mathcal{O}_X\otimes_{f^{-1}\mathcal{O}_Y}f^{-1}G
=f^*G$ (here $\otimes_{\mathrm{p}}$ means tensor product presheaf).
In the particular case $G=\mathcal{O}_Y$, one can check that the unit equals $f^\sharp$, so that our general definition is compatible with the particular case above. On the other hand, naturality of the unit implies equivalence with red_trumpet's definition, i.e., the following diagram commutes
$$
\require{AMScd}
\begin{CD}
\mathcal{O}_Y@>>> G\\
@VVV@VVV\\
f_*\mathcal{O}_X=f_*f^*\mathcal{O}_Y@>>> f_*f^*G
\end{CD}
$$
where the left map is $f^\sharp:\mathcal{O}_Y\to f_*\mathcal{O}_X$.
Naturality of the unit also allows to prove the following: if $\varphi:G\to G'$ is a morphism of sheaves of $\mathcal{O}_Y$-modules and $s$ is a local section of $G$, then $f^*(\varphi (s))=(f^*\varphi)(f^*s)$. (Write the naturality square of the unit of $f^*\dashv f_*$ for the morphism $\varphi$ and apply Definition 1.)
Similarly, by naturality of the unit of $f^{-1}\dashv f_*$, one shows a formula $f^{-1}(\varphi (s))=(f^{-1}\varphi)(f^{-1}s)$ for a morphism of sheaves of sets $\varphi$ over $Y$.
Note that from red_trumpet's definition it is easy to show that pullingback sections is a contravariantly functorial operation: if $X\xrightarrow{f}Y\xrightarrow{g}Z$ are morphisms of ringed spaces, $H$ is a sheaf of $\mathcal{O}_Z$-modules and $t\in\mathcal{O}_Z(W)$, by using the isomorphism of functors $(g\circ f)^*\cong f^*\circ g^*$ one gets $(g\circ f)^*(t)=f^*(g^*(t))$. Similarly, one shows a formula $(g\circ f)^{-1}(t)=f^{-1}(g^{-1}(t))$ for composable continuous maps of topological spaces $f,g$.
For a very detailed description of the action of the unit $G\to f_*f^*G$ on sections, see Alex Kruckman's answer (it's the composite at the end of his answer). On the level of stalks, the morphism $G(U)\to f^*G(f^{-1}(U))$ is the unique map such that for all $x\in f^{-1}(U)$ the following diagram commutes:
$$
\require{AMScd}
\begin{CD}
G(U)@>>> f^*G(f^{-1}(U))\\
@VVV@VVV\\
G_{f(x)}@>>>(f^*G)_x\cong G_{f(x)}\otimes_{\mathcal{O}_{Y,f(x)}}\mathcal{O}_{X,x}
\end{CD}
$$
where the bottom map sends $s_{f(x)}$ to $s_{f(x)}\otimes 1\in G_{f(x)}\otimes_{\mathcal{O}_{Y,f(x)}}\mathcal{O}_{X,x}$. That is, $\operatorname{germ}_x^{f^*G}(f^*s)=s_{f(x)}\otimes 1$. To prove this, consider the map $\tilde{s}:\mathcal{O}_Y\to G$ coming from $s\in\Gamma(G,Y)$ and study the map induced by $f^*\tilde{s}$ on stalks at $x\in X$ (and use [SP, 0098]).
Alternatively, prove that $(f^{-1}s)_x=s_{f(x)}$ via the isomorphism of [SP, 008H], so that $(f^*s)_x=(f^{-1}s\otimes 1)_x=(f^{-1}s)_x\otimes 1=s_{f(x)}\otimes 1$.
We also have a compatibility of the pullback section with the adjunction $f_*\dashv f^*$ itself. Namely, let $f:X\to Y$ be a morphism of ringed spaces, let $F$ be an $\O_X$-module, $G$ be an $\O_Y$-module and $\varphi^\sharp:G\to f_*F$ be a morphism of $\O_Y$-modules whose adjunct is $\varphi^\flat:f^*G\to F$. Then, for $s\in G(V)$, we have $\varphi^\sharp_V(s)=\varphi^\flat_{f^{-1}(V)}(f^*s)$. This follows from the fact that
$$
\varphi^\sharp:G\xrightarrow{\eta}f_*f^*G\xrightarrow{f_*\varphi^\flat}f_*F.
$$
Let's see how all this applies to schemes. Let $X$ be a ringed space and let $R$ be a ring. Let $f:X\to S=\Spec R$ be a morphism of ringed spaces. Let $M$ be an $R$-module. Then $f^*\widetilde{M}$ is the sheafification of the presheaf of $\O_X$-modules $f^*M:U\mapsto M\otimes_R\O_X(U)$. This follows from [SP, 01BJ] and because $\F_M\cong\widetilde{M}$, where $\F_M:=\pi^*M$ and $\pi:S\to(\{*\},R)$, see proof of [SP, 01I7]. (I wished someone had introduced me to the presentation of $f^*\widetilde{M}$ as $(f^*M)^{\#}$ long time ago.)
Proposition. Let $f:X\to S=\Spec R$ be a morphism of ringed spaces. Let $M$ be an $R$-module. Let $s\in M=\Gamma(S,\widetilde{M})$.
- We have:
$$
\tag{1}\label{eq}
f^*s=s\otimes 1
$$
as global sections of $f^*\widetilde{M}$, where the RHS is viewed as an element of $\Gamma(X,f^*\widetilde{M})$ under the map $\Gamma(X,f^*M\to f^*\widetilde{M})=(M\otimes_R\Gamma(X,\O_X)\to\Gamma(X,f^*\widetilde{M}))$.
- Suppose $X=\Spec A$ is an affine scheme and $f$ is a morphism of schemes. Then $\widetilde{M}\to f_*f^*\widetilde{M}$ is the unit map $M\to (M\otimes_RA)_R$, $s\mapsto s\otimes 1$ under the functor $\widetilde{(-)}:\Mod(R)\to\Mod(\O_S)$.
Proof. Point 2 follows from Point 1, but note that Point 2 can be proven independently, for we have $f_*f^*\widetilde{M}=((M\otimes_RA)_R)\widetilde{}$ by [SP, 01I9].
Here are two ways of proving the second point:
$\underline{\text{First proof}}\text{:}$ Verifying \eqref{eq} amounts to verifying it on stalks. The result follows when mapping $(1\otimes s)_x$ under the isomorphism:
\begin{align*}
(f^*M)_x&\cong\O_{X,x}\otimes_RM
&\text{(tensoring commutes with all colimits)}\\
&\cong(\O_{X,x}\otimes_{\O_{S,f(x)}}\O_{S,f(x)})\otimes_RM\\
&\cong\O_{X,x}\otimes_{\O_{S,f(x)}}(\O_{S,f(x)}\otimes_RM)\\
&\cong\O_{X,x}\otimes_{\O_{S,f(x)}}\widetilde{M}_{f(x)}.
\end{align*}
$\underline{\text{Second proof}}\text{:}$ Denote $f_\p^*\G=\O_X\otimes_{\mathrm{p},f^{-1}_\p\O_S}f^{-1}_\p\G$ to the pullback presheaf (this was discussed here). For a sheaf $\F$ of $\O_X$-modules, we have
\begin{align*}
\Hom_{\O_X}(f^*\G,\F)
&\cong\Hom_{\O_X}(f_\p^*\G,\F)\\
&\cong\Hom_{f^{-1}_\p\O_S}(f_\p^{-1}\G,\F)\\
&\cong\Hom_{\O_S}(\G,f_*\F).
\end{align*}
Therefore, the unit of the adjunction $f^*\dashv f_*$ in sheaves of modules may be computed as
$$
\label{unit}\tag{3}
\G
\to f_*f^{-1}_\p\G
\to f_*(f_\p^{-1}\G\otimes_{\p,f^{-1}_\p\O_S}\O_X)
\to f_*(f^{-1}\G\otimes_{f^{-1}\O_S}\O_X).
$$
Thus, for $\G=\widetilde{M}$ and $s\in M$, we have $f^*s=s\otimes 1$ by studying the image of $s$ under \eqref{unit}. $\square$
References
[GW] U. Görtz, T. Wedhorn, Algebraic Geometry I: Schemes, 2nd ed., Springer
[SP] The Stacks Project Authors, The Stacks Project
Warning for the differential geometers (there is some terminological overload): given a smooth manifold $M$, denote $C^\infty_M$ to the sheaf of $\mathbb{R}$-algebras of smooth real-valued functions on $M$. Given a vector bundle $\pi:E\to M$, denote $\Sigma_E$ to the sheaf of $C^\infty_M$-modules of smooth sections of $\pi$. A smooth map of smooth manifolds $f:M\to N$ induces the pullback of covector fields $\varphi:\Sigma_{T^*N}\to f_*\Sigma_{T^*M}$ (that in turns induces the pullback of differential $k$-forms $\Omega_N^k\to f_*\Omega_M^k$), which is a morphism of $C_N^\infty$-modules. The map $\varphi$ should not be confused with the unit $\Sigma_{T^*N}\to f_*f^*\Sigma_{T^*N}$. Actually, $\varphi$ equals
$$
\Sigma_{T^*N}
\to f_*f^*\Sigma_{T^*N}
\to f_*\Sigma_{T^*M},
$$
where $f^*\Sigma_{T^*N}\to \Sigma_{T^*M}$ is the adjoint map to $\Sigma_{T^*N}\to f_*\Sigma_{T^*M}$.