This, for reference see the book High Speed Digital Design by Hall Hall and McCall
https://archive.org/details/highspeeddigital0000hall/
The sharper the edge of the digital pulse, the greater the strength of the AC high frequency components.
A perfect square wave is the sum of the infinite series of odd harmonics of a sine wave with the same wavelength.