Show that there is no non-zero polynomial $P(u,v)$ in two variables with real coefficients such that $P(x, \cos x) = 0$ holds for all real $x$

I came across the following real analysis problem while reviewing, and I am genuinely stuck on this one:

Show that there is no non-zero polynomial $P(u,v)$ in two variables with real coefficients such that $P(x, \cos x) = 0$ holds for all real $x$.

I just don't have any intuition about the non-existence of such a $P$. Am I missing something obvious? Starting out on the problem, why would you expect the above statement to be true?

Suppose such a $P$ exists; in fact, suppose $P$ is the lowest degree such polynomial. Note that $P(x, 0)$ is a polynomial in $x$ and for any $k \in \mathbb{Z}$,
$$P\left(\frac{\pi}{2} + k\pi, 0\right) = P\left(\frac{\pi}{2} + k\pi, \cos\left(\frac{\pi}{2} + k\pi\right)\right) = 0$$
where the last equality holds because $P(x, \cos x) = 0$ for every $x$. But then $P(x, 0)$ has zeroes at $x = \frac{\pi}{2}+k\pi$ for every $k \in \mathbb{Z}$. As $P(x, 0)$ is a polynomial, we must have $P(x, 0) = 0$ for all $x$, so $P(x, y) = yQ(x, y)$ for some real polynomial $Q$.
Note that $P(x, \cos x) = (\cos x)Q(x, \cos x) = 0$. For any $x \neq \frac{\pi}{2}+k\pi$, $\cos x \neq 0$ so for any such $x$, $Q(x, \cos x) = 0$. As $Q(x, \cos x)$ is continuous, we must have $Q(x, \cos x) = 0$ for all $x$. But $Q$ has strictly smaller degree than $P$ which is a contradiction.
You can write $P(u,v)=\sum_{k=0}^n q_k(v)u^k$ where the $q_k$ are real polynomials in one variable. We are given that, for any $a\in[-1,1]$, the polynomial in $u$ given by $P(u,a)$ has infinitely many zeros, because the equation $\cos u=a$ has infinitely many solutions. This means that $q_k(a)=0$ for all $k$. Since $a\in[-1,1]$ is arbitrary, this means that each $q_k$ is identically zero.