4. Given the parabola $y=a x^{2}+b x+c(a>0)$ and the line $y=k(x-1)-\frac{k^{2}}{4}$. Regardless of the value of $k$, the parabola and the line have only one common point. Then, the equation of the parabola is ( ).
(A) $y=x^{2}$
(B) $y=x^{2}-2 x$
(C) $y=x^{2}-2 x+1$
(D) $y=2 x^{2}-4 x+2$
4.C.

From $\left\{\begin{array}{l}y=a x^{2}+b x+c, \\ y=k(x-1)-\frac{k^{2}}{4}\end{array}\right.$ we get
$$
a x^{2}+(b-k) x+c+k+\frac{k^{2}}{4}=0 \text {. }
$$

By the problem statement, equation (1) has two equal real roots, so
$$
\Delta=(b-k)^{2}-4 a\left(c+k+\frac{k^{2}}{4}\right)=0 \text {, }
$$

which simplifies to $(1-a) k^{2}-2(2 a+b) k+b^{2}-4 a c=0$.
Since $k$ is any real number, we have
$$
\left\{\begin{array}{l}
1-a=0, \\
2 a+b=0, \\
b^{2}-4 a c=0 .
\end{array}\right.
$$

Solving these, we get $a=1, b=-2, c=1$.
Thus, the equation of the parabola is $y=x^{2}-2 x+1$.