If $X,Y$ are locally ringed spaces over a locally ringed space $S$, then one can write down their fiber product $X \times_S Y$ explicitly. If $X,Y,S$ are schemes, then this fiber product *is* a scheme, so that it is the fiber product in the category of schemes. This provides an alternative (and in my opinion far better) construction of the fiber product of schemes which is not well-known as it should be. You can find it here. Let me sketch it:

Let $f : X \to S$ and $g : Y \to S$. The underlying set of $X \times_S Y$ consists of those triples $(x,y,s,\mathfrak{p})$, where $(x,y,s)$ lies in the underlying topological fiber product, i.e. $x \in X, y \in Y, s \in S$ and $f(x)=s=g(y)$, and $\mathfrak{p}$ is a prime ideal in $\kappa(x) \otimes_{\kappa(s)} \kappa(y)$, the tensor product of the residue fields. In other words, the fiber of the map from $X \times_S Y$ to the topological fiber product is precisely $\mathrm{Spec}(\kappa(x) \otimes_{\kappa(s)} \kappa(y))$ at the point $(x,y,s)$. Note that $\mathfrak{p}$ can also be equivalently described as a prime ideal $\mathfrak{q}$ in the tensor product of the local rings $\mathcal{O}_{X,x} \otimes_{\mathcal{O}_{S,s}} \mathcal{O}_{Y,y}$, which restricts to the maximal ideals in $\mathcal{O}_{X,x}$ and $\mathcal{O}_{Y,y}$ (and therefore also in $\mathcal{O}_{S,s}$, since $f^\#_x$ and $g^\#_y$ are local).

The topology looks as follows: If $U \times_T V$ is a basic open subset of the topological fiber product (i.e. $U \subseteq X, V \subseteq Y, T \subseteq S$ open wih $f(U) \subseteq T \supseteq g(V)$) and $f \in \mathcal{O}_X(U) \otimes_{\mathcal{O}_S(T)} \mathcal{O}_Y(V)$, then $\Omega(U,V,T,f) \subseteq X \times_S Y$ consists of those $(x,y,s,\mathfrak{q})$ such that $x \in U, y \in V, s \in T$ and that the image of $f$ in $\mathcal{O}_{X,x} \otimes_{\mathcal{O}_{S,s}} \mathcal{O}_{Y,y}$ is not contained in $\mathfrak{q}$. These sets form a basis for a topology on $X \times_S Y$. The structure sheaf is defined in such a way that on local rings $\mathcal{O}_{X \times_S Y,(x,y,s,\mathfrak{q})} = (\mathcal{O}_{X,x} \otimes_{\mathcal{O}_{S,s}} \mathcal{O}_{Y,y})_{\mathfrak{q}}$. A general section in $\mathcal{O}_{X \times_S Y}$ is a function valued in these stalks, which is locally a fraction.

Of course, all this is not needed to see that the affine line with doubled origin is not separated. And once again I cannot recommend to read Hartshorne for the basics of algebraic geometry. If $X_1$ and $X_2$ are equal affine schemes and $U$ is an open subscheme, then $X=X_1 \cup_U X_2$ is separated iff $X_1 \times_X X_2 = X_1 \cap X_2 = U$ is affine, and $U \to X_1 \times X_2$ is a closed immersion. In particular, the affine line with a doubled origin is not separated.

## Best Answer

In this example, it is still not true that $X\times_k X = X\times X$ as topological spaces, since for example on the complement of the origin(s), the two are not equal. This follows for the same reason as your previous example: the Zariski topology on $\mathbb A^2$ is not equal to the product topology on $\mathbb A^1\times\mathbb A^1$.

What is true in both cases is that there is a natural correspondence between closed points of the fibre product and products of closed points. This follows because we know that maximal ideals of $K[x,y]$ have the form $(x-a,y-b)$ for $a,b\in K.$