How should we think about the sections of a sheaf on a scheme as functions?

Given a ring $A$ the structural sheaf $\mathcal O_X$ of the affine scheme $X=\operatorname {Spec}A$ is indeed the sheaf associated to a very natural presheaf, namely the presheaf of rings $\mathcal O'_X$ defined as follows:

For an open subset $U\subset X$, the ring $\mathcal O'_X(U)$ is the ring of fractions $$\mathcal O'_X(U)=S(U)^{-1}O_X(U)$$ where the multiplicative set $S(U)$ is $$S(U)=\{f\in A\vert\,\forall \mathfrak p\in U, f\notin \mathfrak p\}$$ You can find an example proving that in general $O'_X(U)\neq O_X(U)$ here.
Note that for $U$ of the form $U=D(f) \; (f\in A)$ we do have $O'_X(U)= O_X(U)$: Hartshorne Proposition 2.2 (b), page 71 in chapter II.

Edit: and what about differential manifolds?
It is an extremely amazing and underappreciated fact for an open subset $U\subset X$ of a differential manifold $X$ we do have $$C^\infty(U)=\{\frac {g\vert U}{f\vert U}: f,g\in C^\infty(X)\operatorname {and}\forall x\in U, f(x)\neq0 \}$$ So if manifolds are seen as locally ringed spaces (as they should!) we do have in that category $\mathcal O_{X,\operatorname {diff}}^{'}= \mathcal O_{X,\operatorname {diff}}$ !
One of the very rare references on this result is Nestruev, Proposition 10.7, page 145.


If $X$ is a scheme over a field, then we can really interpret a section as a function with values in the field.

Note that for any open $U \subset X$ a morphism $U \to \mathbb A^1_k = \operatorname{Spec}k[x]$ is the same as a map $k[x] \to \mathcal O_X(U)$ and by the universal property of the polynomial ring this is the same as a choice of an element $f \in \mathcal O_X(U)$. Thus we have natural bijection between section of the structure sheaf and morphisms to the affine line. If $k$ is algebraically closed, the points of the affine line can be interpreted as points in $k$.