Let $M,N\subset\mathbb{P}^n$ quasiprojective varieties such that there exist isomorphisms $i\colon M\rightarrow Z(a)\subset \mathbb{A}^m$ and $j\colon N\rightarrow Z(b)\subset \mathbb{A}^m$ for ideals $a,b\subset k[x_1,...,x_m]$ (here $Z(a)$ denotes the set of zeros of the functions on the ideal $a$). Prove that $M\cap N$ is isomorphic to an affine set $Z(c)\subset \mathbb{A}^k$ for some $k$ and some $c\subset k[x_1,...,x_k]$.
I know that the intersection of zero sets is again a zero set, but here I can't assume that the zero sets $Z(a)$ and $Z(b)$ even have non-empty intersection. Composing the maps $i$ and $j^{-1}$ we can find and isomorphism between the subsets of $Z(a)$ and $Z(b)$ corresponding to the image of $M\cap N$. Thanks in advance for the help!
Consider the diagonal morphism $M\cap N\to M\times N$ where $x\mapsto(x,x)$. Since $M$ and $N$ are affine, so is $M\times N$. We see that $M\times N\subseteq\mathbb{P}^n\times\mathbb{P}^n$. Let $\Delta$ be the diagonal; it is closed since $$\Delta=\{([x_0:\cdots:x_n],[y_0:\cdots:y_n])\in\mathbb{P}^n\times\mathbb{P}^n:x_iy_j-x_jy_i=0,i,j=0,\ldots,n\}.$$ Therefore $$M\cap N\simeq (M\times N)\cap\Delta$$ which is a closed subset of an affine variety, and is therefore affine.
Note: Notice that this proof works whenever your $M$ and $N$ live inside something (i.e. a scheme or variety) where the diagonal is closed. This is essentially what separatedness is all about.