The apparent contradiction is caused by the fact that the autocorrelation function is defined differently for different signal classes. For deterministic signals with finite energy, the autocorrelation is defined as
$$r_x(\tau)=\int_{-\infty}^{\infty}x(t)x(t+\tau)dt\tag{1}$$
Its Fourier transform is the squared magnitude of the Fourier transform of the signal, which equals the energy density spectrum:
$$\mathcal{F}\big\{r_x(\tau)\big\}=\big|X(\omega)\big|^2\tag{2}$$
For deterministic signals with finite (but non-zero) power, the autocorrelation is defined as a limit:
$$r_x(\tau)=\lim_{T\to\infty}\frac{1}{T}\int_{-T/2}^{T/2}x(t)x(t+\tau)dt\tag{3}$$
The Fourier transform of the autocorrelation given by $(3)$ is the power spectrum of the deterministic signal $x(t)$. It can be shown that the power spectrum can also be directly expressed in terms of $x(t)$:
$$S_x(\omega)=\lim_{T\to\infty}\frac{1}{T}\left|\int_{-T/2}^{T/2}x(t)e^{-j\omega t}dt\right|^2\tag{4}$$
Finally, if a signal is modeled as a wide-sense stationary process, its autocorrelation is defined in terms of the following expectation:
$$R_X(\tau)=E\big\{X(t)X(t+\tau)\big\}\tag{5}$$
As to be expected, the corresponding power spectrum is given by the Fourier transform of $(5)$.
Hence, even though in all cases we compute the Fourier transform of an autocorrelation function, the results are different due to the different definitions of the autocorrelation function for various signal types.
fft, doesn't make them same. – OverLordGoldDragon May 05 '23 at 16:00