At the end of a proof on the Stacks project showing that the union of disjoint open affines is affine, we have the following statement
By assumption the morphism $X \rightarrow \operatorname{Spec}(X)$ induces an isomorphism of $\operatorname{Spec}(\mathcal{O}_X(U))$ with $U$ and similarly for $V$. Hence $X \rightarrow \operatorname{Spec}(R)$ is an isomorphism.
Why is there an induced isomorphism (i.e. why is it an isomorphism, not just a morphism)? What is the induced isomorphism?
As an aside, the proof on the Stacks project uses the fact that the $\operatorname{Spec}$ of a product is a coproduct of $\operatorname{Spec}$, so why not use a one line proof à la this proof?