We proceed using induction on the degree of \(p\). It's evident that \(p\) must have even degree, and the proposition is trivial for \(p\) constant. Since \(p\) has even degree, it has a non-negative global minimum, say \(m\) . Then \( p-(\sqrt{m})^2 \) is tangent to the x-axis and so is divisible by \((x-c)^2\) for some real \(c\) . Then \(\frac{p-(\sqrt{m})^2}{(x-c)^2} \) is expressible as a sum of squares by assumption, and we simply need to multiply through by \( (x-c)^2 \) and add \(\sqrt{m}^2\) to get that \(c\) is as well.
This argument can be easily refined to again get that \(k=2\) suffices.