This is a bit embarrassing (and hopefully hasn't been asked before). Let $F$ be a field and $p(x,y)$ be a polynomial in $F[x,y]$. Suppose that $p(x,x)=0$. For most authors it is obvious that this implies that $x-y$ is a factor of $p$. For me, however, it doesn't seem so easy. The only argument I found is the following: Consider $p$ as a univariate polynomial in $y$ over the function field $F(x)$. Then $p$ has the root $x$, so we can factor the linear term $y-x$ (using that $F(x)[y]$ is an Euclidean domain). Since $y-x$ is monic, the polynomial division does not introduce denominators. Hence, the complementary factor lies in $F[x,y]$.
Question: Is there a more direct argument?
It's an excellent question. One which I've thought about before. I believe your proof, of looking at $p(x, y)$ as a polynomial over $F[x]$ or $F(x)$ is the most direct argument.
The other argument is using the Nullstellensatz which—among other things—says that $I(V(x - y)) = (x - y)$. In words: a polynomial vanishes on the line $y = x$ if and only if it belongs to the ideal $(x - y)$. If you look at the (constructive) proofs of the Nullstellensatz, you get an idea of what sorts of arguments will apply to your question: