Question: "I understand why this works on a very technical level, essentially it seems to be because this diagram commutes (which is mostly because a map of affine schemes is given by its map of global sections):
$$\text{ }$$
If the map is defined on functions, then why does it seem like the arrow is going in the wrong direction?"
Answer:
A "set theoretic" map: For simplicity let us study the projective line and the map
$$\pi: S:=\mathbb{A}^2_k-\{(0,0)\}\rightarrow C:=\mathbb{P}^1_k$$
defined "pointwise" by $\pi(a,b):=(a:b) \in C$. if $\lambda \in k^*$ it follows $\pi(\lambda a, \lambda b):=(\lambda a: \lambda b)=(a:b)$. There is a "set theoretic" action of $k^*$ on $S$ and $\pi(\lambda p)=\pi(p)$.
A "scheme map": We want to define a surjective map of schemes $\pi: S \rightarrow C$, using an open cover.
Let $C$ have homogeneous coordinates $x_0,x_1$ and let $S:=Spec(k[x,y])-\{(0,0)\}$.
Let $D(x_0):=Spec(k[x_1/x_0])$ and let $D(x_1):=Spec(k[x_0/x_1])$. Define the maps
$$\phi_0:k[x_0/x_1] \rightarrow k[x,y,1/y]$$
by $\phi_0(x_0/x_1):= x/y$ and define
$$\phi_1:k[x_1/x_0] \rightarrow k[x,1/x,y]$$
by $\phi_1(x_1/x_0):=y/x$. There is a well defined induced map
$$\rho:k[x_0/x_1,x_1/x_0] \rightarrow k[x,1/x,y,1/y]$$
since $1=(x_0/x_1)(x_1/x_0) \rightarrow (x/y)(y/x).$ You get
$$1=\rho(1)=\rho((x_0/x_1)(x_1/x_0))=(x/y)(y/x)=1$$
hence the induced map $\rho$ is well defined: The maps $\phi_0,\phi_1$ glue.
Example: The "scheme maps" induced by $\phi_0,\phi_1$ are (at the level of $k$-rational points) as follows:
$$\phi_0^*(a,b):= a/b$$
and
$$\phi_1^*(a,b):=b/a.$$
Here $\mathfrak{m}:=(x-a,y-b) \subseteq k[x,y]$ is a $k$-rational point with $(a,b) (\neq (0,0)) \in k^2$. Equivalently, at the level of maximal ideals you get
$$\phi_0^{-1}(x-a,y-b)=(x_1/x_0-a/b)$$
and
$$\phi_1^{-1}(x-a,y-b)=(x_0/x_1-b/a).$$
Hence the maps $Spec(k[x,y,1/y])\rightarrow D(x_1)$ and $Spec(k[x,1/x,y]) \rightarrow D(x_0)$ glue to a "global" surjective map of schemes $\pi: S \rightarrow C$. The map $\pi$ has the property that
$$\pi^{-1}(D(x_i)) \cong Spec(k[t,1/t]) \times_k \mathbb{A}^1_k \cong GL(1,k)\times_k \mathbb{A}^1_k,$$
for $i=0,1$. The map $\pi^{-1}(D(x_i)) \rightarrow D(x_i) \cong \mathbb{A}^1_k$ is the projection map. Hence $\{D(x_i)\}$ is a trivialization of $\pi$ in the Zariski topology. The map $\pi$ is a "principal $GL(1,k)$-bundle" on $C$. The group scheme $GL(1,k):=Spec([t,1/t])$ has as $k$-rational points $k^*$ - the multiplicative group of non-zero elements in $k$.
Note: There is a well defined action
$$\sigma: GL(1,k) \times_k S \rightarrow S$$
and an isomorphism $S/GL(1,k) \cong C$. Hence you may view the projective line $C$ as the "geometric quotient" (in the sense of Mumford) of $S$ by $GL(1,k)$.
Example: Projective space: This construction generalize. Let $X:=\mathbb{A}^{n+1}_k-\{(0,..,0)\}$ and define similarly a map
$$\gamma: X \rightarrow Y:=\mathbb{P}^n_k.$$
Let $D(x_i) \subseteq Y$ be the "standard" open affine cover of $Y$. It follows
$$\pi_i: \pi^{-1}(D(x_i)) \cong GL(1,k)\times_k D(x_i) \rightarrow D(x_i)$$
is the projection map onto $D(x_i)$. There is an action
$$\sigma: GL(1,k)\times_k X \rightarrow X$$
and an isomorphism $X/GL(1,k) \cong Y$. Hence $Y:=\mathbb{P}^n_k$ is the "geometric quotient" of $X$ by $GL(1,k)$. $Y$ is a principal $GL(1,k)$-bundle and $D(x_i)$ is a local trivialization of $\pi$.
Note: If you wish to study this topic you should - as an exercise - generalize the above construction to projective space of any dimension: Write down explicit formulas for the maps of rings and prove that they glue to give a global map of schemes.
Your comment: "...there is no need to check gluing because the map is globally defined. So my question is: Is this map globally defined on points or on functions? "
The problem is that $X$ is a non-affine scheme, and to construct a map you must define it locally and prove it glues to a global map. If $U:=Spec(B), V:=Spec(A)$ it follows
$$F1.\text{ }Hom_{Sch}(U,V) \cong Hom_{rings}(A,B).$$
Hence for affine schemes you define a map $\phi: U \rightarrow V$ via a map $f: A\rightarrow B$. Since $X$ above is non-affine you use formula $F1$ locally and define maps locally. To get a well defined global map of schemes you must prove that these locally defined maps glue (agree on intersections).
It seems to me this is what is "explained" on the photo, but there are no explicit formulas. Above I give such formulas for the projective line.
Example: More generally you may for $X:=\mathbb{A}^{n+1}_k -\{(0)\}$ construct a left $G:=GL(1,k)$-action $\sigma_a$ on $X$ which "pointwise" is the action (let $a:=(a_0,..,a_n)\in \mathbb{Z}^{n+1}$)
$$\sigma_a(\alpha,(x_0,..,x_n)):=(\alpha^{a_0}x_0,..,\alpha^{a_n}x_n)$$
and you may ask for a construction of the quotient $X/G$. This is how weighted projective space is constructed. The canonical map $\pi: X \rightarrow X/G:=\mathbb{P}(a_0,..,a_n)$ is a principal $G$-bundle. If $a_i=1$ for all $i$ you get projective space. You may also construct multi projective space as an "algebraic stack" (a stack quotient) using this construction.
Note: The map $\pi: X:=\mathbb{A}^{n+1}_k-\{(0)\} \rightarrow \mathbb{P}^n_k$ is a map of schemes and you get canonically an induced map of functors of points
$$ h_{\pi}:h_X \rightarrow h_{\mathbb{P}^n_k},$$
and the functor $h_{\mathbb{P}^n_k}$ may be defined as "a functor parametrizing line bundle quotients". You may also try to construct $h_{\pi}$
using this language, but the above construction is "more elementary" and "direct".