I want to respond to one particular statement you made, but first I'll make things a bit more precise.
We have the adjunction $$\newcommand\Hom{\operatorname{Hom}}\newcommand\Spec{\operatorname{Spec}}\newcommand\calO{\mathcal{O}}\Hom(X,\Spec A)\simeq \Hom(A,\Gamma(X,\calO_X)),$$ and in particular this tells us that
$$\Hom(X,\Spec \Gamma(X,\calO_X))\simeq \Hom(\Gamma(X,\calO_X),\Gamma(X,\calO_X)).
$$
The identity map $\Gamma(X,\calO_X)\to\Gamma(X,\calO_X)$ therefore gives us a map of schemes $X\to \Gamma(X,\calO_X)$ as you noticed, and this is indeed the canonical map. However, you seem to be under the impression that this map is therefore an isomorphism.
In general this cannot possibly be true, since if the map were an isomorphism, $X$ would necessarily have to be affine. However, if $X$ is affine, this map is indeed an isomorphism.
Let's be a little more clear how this map works then.
In fact let's be a little more clear how it works in general. Let $\phi : A\to \Gamma(X,\calO_X)$ be a ring morphism. Let's try to understand the induced map $f : X\to \Spec A$.
Let $U$ be an affine open in $X$. Then we have the maps
$$\newcommand\toby\xrightarrow A\toby{\phi}\calO_X(X)\toby{r_{XU}} \calO_X(U).$$
Taking $\Spec$ of this sequence gives
$$U\toby{\Spec r_{XU}} \Spec \calO_X(X) \toby{\Spec \phi} \Spec A.$$
Gluing these maps together gives the desired map from $X$ to $\Spec A$.
Observe then that if $\phi=\newcommand\id{\operatorname{id}}\id$, that the map $X\to \Spec \Gamma(X,\calO_X)$ is the result of gluing the maps obtained from applying the Spec functor to the restrictions $r_{XU}:\calO_X(X)\to \calO_X(U)$.
If $X$ is affine, then we can take $U=X$, and there's no need to glue, the map $X\to \Spec\Gamma(X,\calO_X)$ is $\Spec \id=\id$. On the other hand, if $X$ is not affine, for example, if $X$ is a projective $k$-scheme with $k$ algebraically closed, then $\Gamma(X,\calO_X)=k$, and $X\to \Spec\Gamma(X,\calO_X)$ is the $k$-scheme structure morphism $X\to \Spec k$, which in general is clearly not an isomorphism.
The notion you have defined is called a localizing morphism in [Nayak, Definition 2.1], at least for morphisms between noetherian schemes. Nayak points out that this definition has some peculiar features. For example, if $Y$ is a noetherian scheme, then we can have the following [Nayak, (2.4)]:
- Let $X$ be the scheme obtained by gluing two open sets $U \subseteq Y$ and $V \subseteq Y$ along a nonempty open subset in $U \cap V$. Then, $X \to Y$ is a localizing morphism that is not separated in general.
- Let $\{U_i\}$ be a finite collection of open subsets of $Y$, and let $X = \coprod_i U_i$. Then, the natural map $X \to Y$ is a localizing morphism that is separated, but is not an open immersion in general.
This is why Nayak defines a localizing immersion between noetherian schemes as a localizing morphism that is set-theoretically injective, or equivalently a localizing morphism that is separated and maps generic points to generic points [Nayak, Lemma 2.6 and Definition 2.7].
You can read about some properties of localizing immersions in [Nayak, (2.8)], but one of the most important results is the following:
Theorem [Nayak, Theorem 3.6]. Let $f\colon X \to S$ be a separated morphism essentially of finite type between noetherian schemes. Then, $f$ factors as
$$X \overset{k}{\longrightarrow} Y \overset{p}{\longrightarrow} S,$$
where $k$ is a localizing immersion and $p$ is separated and of finite type.
Nayak uses this result to obtain a version of Nagata's compactification theorem for separated morphisms essentially of finite type.
Theorem [Nayak, Theorem 4.1]. Let $f\colon X \to S$ be a separated morphism essentially of finite type between noetherian schemes. Then, $f$ factors as
$$X \overset{k}{\longrightarrow} Y \overset{p}{\longrightarrow} S,$$
where $k$ is a localizing immersion and $p$ is proper.
Nayak also obtains versions of Zariski's main theorem [Nayak, Theorem 4.3], Chow's lemma [Nayak, Theorem 4.8], and Grothendieck duality [Nayak, Theorem 5.3] for separated morphisms essentially of finite type.
Best Answer
Let $X$ be a scheme an let $R$ be a ring. Let me maybe suggest you to try to prove the following:
There is a natural bijection $\text{Hom}_{\text{Sch}}(X, \text{Spec}(R)) \cong \text{Hom}_{\text{Ring}}(R, \Gamma(X,\mathcal{O}_X)).$
This is not only a very useful statement, but also implies what you want to prove as you can use that $\mathbb{Z}$ is a initial object in the category of rings like you were doing for the affine case.