One of those mind-blowing things you learn studying Engineering is that functions can be expressed as a sum of sinusoids. The math is pretty well beyond most high school math and physics students but I have had some success presenting the idea and observing the phenomenon. I put together a quick simulation in excel that can be used to generate a sequence of higher-and-higher frequency sine waves that add up to a square wave.
You have to copy the entire column D, and paste it repeatedly into adjacent columns. You can keep going through the graphs into columns I, J, K, etc if you want.
Each column is a sine wave. As we move right through the columns, the frequency increase and the amplitude decreases. You can see all the sine waves together on the lower graph.
On the upper graph, we have the sum of all the superimposed waves. The more higher-frequency waves we add, the more square-like the sum becomes.
If you're curious, have a look at the formulas used to calculate the sine waves. You can also read more about the frequency components of sine waves here.