4. For all real numbers $x$, we have
$$
\sin ^{k} x \cdot \sin k x+\cos ^{k} x \cdot \cos k x=\cos ^{k} 2 x,
$$

then $k=(\quad)$.
(A) 6
(B) 5
(C) 4
(D) 3
4. D.
$$
\text { Let } f(x)=\sin ^{k} x \cdot \sin k x+\cos ^{k} x \cdot \cos k x-\cos ^{k} 2 x \text {. }
$$

Given that $f(x)$ is always 0, taking $x=\frac{\pi}{2}$, we get $\sin \frac{h \pi}{2}$ $=(-1)^{k}$. Therefore, $k$ is an odd number.
Let $k=2 n-1$. Then the equation becomes
$$
\sin \left(n \pi-\frac{\pi}{2}\right)=-1 \text {. }
$$

Thus, $n$ is an even number.
Let $n=2 m$. Then $k=4 m-1$.
Hence, among the options, only $k=3$ satisfies the condition.