This question is a little basic, but I think it is consistent with the goals of MO.

My question is about a certain type of argument in algebraic geometry which exploits the abundance of dense sets in the Zariski topology. A classical example is the Cayley-Hamilton theorem, and I will frame my question by sketching a false proof.

Theorem: Let $A$ be a $n \times n$ matrix with complex entries. Then $p_A(A) = 0$ where $p_A$ is the characteristic polynomial of $A$.

False proof:

Step 1: The theorem is trivial for diagonalizable matrices.

Step 2: The set of diagonalizable matrices is Zariski dense in $\mathbb{C}^{n^2}$ because it contains the complement of the zero locus of the discriminant polynomial.

Step 3: The function $\mathbb{C}^{n^2} \to \mathbb{C}^{n^2}$ given by $A \mapsto p_A(A)$ is Zariski continuous, so it vanishes everywhere since it vanishes on a Zariski dense set.

The Flaw: Step 3 uses the following "fact" (which perhaps belongs as an answer to the "common false beliefs" question): if $f$ and $g$ are continuous functions between topological spaces $X$ and $Y$ which agree on a dense subset of $X$ then they agree everywhere. But this need not be the case if $Y$ is not Hausdorff (and the Zariski topology certainly is not): Let $X = \mathbb{R}$, let $Y$ be the line with the double origin, and let $f, g \colon X \to Y$ be the maps which restrict to the identity on $\mathbb{R} - \{0\}$ and which satisfy $f(0) = 0_1$, $g(0) = 0_2$. I have seen this error in textbooks.

In the case of the Cayley-Hamilton theorem, there is an easy fix: if you give $\mathbb{C}^{n^2}$ the norm topology then the diagonalizable matrices are still dense, $A \mapsto p_A(A)$ is still continuous, and now everything is Hausdorff. But Zariski dense arguments come up a lot in algebraic geometry, sometimes in contexts where there isn't a norm topology conveniently lying around. So my question is: can the problem be fixed in some sort of uniform way?