Let $X\subset \mathbb{C}P^n\times\mathbb{C}P^n\times \mathbb{C}P^n$ be the set of points $\{(x_1,x_2,x_3)\}$ s.t. some $x_i=x_j$, then why is the codimension of $X$ $n$?
Now $X=Z(x_1=x_2)\cup Z(x_3=x_2)\cup Z(x_1=x_3)$ and each union component has codimension $n$. Why is $X$ also with codimension $n$?
Maybe there is confusion that the $x_i$ are like coordinates? But they are not, each $x_i$ is rather a line which itself has $n+1$ homogeneous coordinates.
So, lets change notation from $(x_1,x_2,x_3)$ to $(x,y,z)$. Then $(x,y,z) \in \mathbb CP^n\times\mathbb C P^n \times \mathbb C P^n$, and each variable can be written in homogeneous coordinates like so: $$x = [x_0:\cdots:x_n]$$ $$y = [y_0:\cdots:y_n]$$ $$z = [z_0:\cdots:z_n]$$
Setting for example $x = y$ means that $[x_0:\cdots:x_n] = [y_0:\cdots:y_n]$. When $x_0 = y_0 = 1$, this leaves us with $n$ separate equations to impose, $x_1=y_1,x_2=y_2,\ldots x_n=y_n$. Therefore $Z(x=y)$ is of codimension $n$.