If $K$ is a field, $\mathbb A^2_K=\textrm{Spec}K[X,Y]$ and $U=\mathbb A^2_K\setminus\{(X,Y)\}$, I want to prove that $(U,\mathscr O_{\mathbb A^2_K|U})$ is not an affine scheme. I know that this topic has been handled many times, but I want to point a specific passage in the language of schemes.
I have proved that $\mathscr O_{\mathbb A^2_K|U}(U)=\mathscr O_{\mathbb A^2_K}(\mathbb A^2_K)=K[X,Y]$. Now suppose that $(U,\mathscr O_{\mathbb A^2_K|U})$ is an affine scheme, there is a ring $R$ such that $(U,\mathscr O_{\mathbb A^2_K|U})\cong (\textrm{Spec }R,\mathscr O_{\textrm{Spec}R})$; by the equivalence between the opposite category of rings and the category of affine schemes we have that $R\cong \mathscr O_{\mathbb A^2_K|U}(U)=K[X,Y]$. The conclusion is that $(U,\mathscr O_{\mathbb A^2_K|U})\cong (\mathbb A^2_K,\mathscr O_{\mathbb A^2_K})$ but I don't understand where is the contraddiction. Why $\mathbb A^2_K$ and $U$ shouldn't be homeomorphic (look here for a similar question)? Even if they are homeomorphic (I don't think so) why there shouldn't exist an isomorphism as locally ringed spaces?
The fact that the open embedding is not an isomorphism doesn't imply that there is no isomorphisms between the two schemes.
You've misunderstood the argument. Let's recall the fundamental theorem of affine schemes:
Theorem.
Corollary. The functor $\operatorname{Spec} : \mathbf{CRing}^{\mathrm{op}} \to \mathbf{Sch}$ is fully faithful and has a left adjoint.
Now, let's apply this to the problem at hand.
Lemma. If $X$ and $Y$ are affine schemes, then a morphism $f : X \to Y$ is an isomorphism if and only if the ring homomorphism $f^* : \Gamma (Y, \mathscr{O}_Y) \to \Gamma(X, \mathscr{O}_X)$ is an isomorphism.
Proof. If $f : X \to Y$ is an isomorphism, then $f^* : \Gamma (Y, \mathscr{O}_Y) \to \Gamma(X, \mathscr{O}_X)$ must also be an isomorphism, by functoriality. Conversely, if $f^*$ is an isomorphism, say with inverse $g^* : \Gamma (X, \mathscr{O}_X) \to \Gamma(Y, \mathscr{O}_Y)$, then the fundamental theorem implies there is a unique scheme morphism $g : Y \to X$ inducing $g^*$, and moreover $g$ must be a two-sided inverse for $f$. ◼
Corollary. If $X$ is a scheme, $f : X \to \operatorname{Spec} A$ is a morphism but not an isomorphism, and $f^* : A \to \Gamma (X, \mathscr{O}_X)$ is an isomorphism, then $X$ is not affine.
Proof. This is the contrapositive of the above lemma. ◼
Of course, in the case of interest, $X = U$, $A = K[X, Y]$, and $f : X \to \operatorname{Spec} A$ is the inclusion. This is certainly not an isomorphism: it is not even a bijection on points!