A perfect square wave has infinite bandwidth. The phase change from high to low theoretically happens instantaneously. Practically nothing moves that fast in the real world. Voltages take time to go up and down because of inductance and what not in the circuit, the cone of the speaker needs to start accelerating to move, etc. A speaker cone doesn't move instantaneously from its high point in the wave to the low point in the wave, it takes time for it to move and actually push the air around. Plus, the air itself is kind of springy, so even if the speaker did move instantaneously (which it can't, it would have to move at infinite acceleration) the resulting pressure wave wouldn't be nearly as sharp of a transition.
Your ears don't experience pure square waves. They can't. They'll get the approximation of a square wave as close as they can experience them, but your ear drum doesn't immediately warp from one point to another. It gradually moves. The fluid in your ear has its own springiness. The hairs which do the final detection don't just instantly move either, they're being vibrated by the motion of the fluid in your ear.
And yeah, technically your eardrums can be moved by waves higher than 20kHz. But its not just the motion of your ear drums that give you hearing, its lots of tiny hairs in your inner ear that resonate at different frequencies that gives you the detection of certain audio frequencies that are present. Normal humans (read: practically everyone) tend to only have the equipment to accurately sense up to ~20kHz pressure waves with our ears as sound. As you age the areas which detect higher frequency sounds get less sensitive first, so you start losing the ability to hear those higher frequency sounds first.
It does seem like you're missing a bit of knowledge about signal theory though. That would really help you understand what I mean when I say a real square wave has infinite bandwidth. A very rough and basic idea to help here is that a wave can be thought of as a sum of fundamental sine waves. So a square wave is essentially the sum of all the component fundamentals, each fundamental gets sharper and sharper edges of the square. But the only way for the sine wave to have a truly vertical edge is to be infinite frequency, right? And what are the edges of a square wave? Vertical lines. So to keep adding these fundamentals together to achieve a square output, you'd need to add an infinite sum of sines together to make an actually perfect square. Monty touches on this in that video a bit, but it goes pretty quick.
Thanks again for your detailed comment. I think I understand it now. The only thing slightly puzzling me is why waves are broken up (be it Fourier or in our ears) into sine waves, and not say sawtooth (or some other, like a semicircle as in https://math.stackexchange.com/questions/1019005/what-kind-o...) waveform.
I understand how a squarewave needs infinite bandwidth for decomposing into sine waves, but a wave like the semicircle one has a vertical tangent and would not need an infinite bandwidth. Btw you're right, I've never had any signal theory classes (studied mech engg).
I'm mostly just an amateur myself, so I totally get where you're coming from.
FWIW, the graph at the top of that article (as mentioned in the comments) does not have vertical tangents. They're not true semicircles. Most of the answers given to make actual semicircles become non-continuous signals (y >= 0 if ... answer) or infinite sum. The one which doesn't just says they look like semicircles. I don't really have the time (or immediate knowledge, I'm admittedly bad at math) to dig all the math but my gut instinct suggests those aren't true semicircles and don't truly have vertical tangents.
And this is kind of how a signal generator can get away making square waves and sawtooths and what not; internally its not always truly "discrete" signals its just quickly flipping a switch from one thing to another. It flips from the high state to the low state fast enough that for your 50MHz oscope it looks pretty continuous, and its probably designed to try and draw a connected line.
This all kind of makes some sense when you get into how we actually make electrical signals. We're normally just modulating the electric "vibrations" of some crystal or accelerating some magnet through a loop back and fourth. These things move in continuous waves. As mentioned, things don't have infinite acceleration they take time to shift between states. So you're never going to get something that goes from high to low in zero time. And most home owners will tell you there's no such thing as a right angle.
I'd like to mention though, you're imaging the wave as being "broken up" into sine waves, which IMO isn't quite the right way to be looking at it. Its not "breaking up" the signal into sine waves, the signals were always sine waves. Remember my comment, truly square waves don't really exist. We can have things that kinda look square-ish when you squint your eyes, but they're not really square waves. A truly square wave in reality requires infinite acceleration or its not continuous. Fill a bathtub and try to make square waves. Its just not going to happen.
I know I'm not fully answering your question, I don't fully know the answer myself. So far in my stumbling around the closest thing I can answer is because that's just how nature and waves are, at least as much as our monkey brains can reason about them. Think about a string in a guitar or a wave in the water or throwing a ball. They all moves in ways which can be described by sine waves. Its just like the nature of how things accelerate and move, changing between states. Why do we see the golden ratio in so many places? Why are circles so special? Good luck on digging for more truth.
Your ears don't experience pure square waves. They can't. They'll get the approximation of a square wave as close as they can experience them, but your ear drum doesn't immediately warp from one point to another. It gradually moves. The fluid in your ear has its own springiness. The hairs which do the final detection don't just instantly move either, they're being vibrated by the motion of the fluid in your ear.
And yeah, technically your eardrums can be moved by waves higher than 20kHz. But its not just the motion of your ear drums that give you hearing, its lots of tiny hairs in your inner ear that resonate at different frequencies that gives you the detection of certain audio frequencies that are present. Normal humans (read: practically everyone) tend to only have the equipment to accurately sense up to ~20kHz pressure waves with our ears as sound. As you age the areas which detect higher frequency sounds get less sensitive first, so you start losing the ability to hear those higher frequency sounds first.
It does seem like you're missing a bit of knowledge about signal theory though. That would really help you understand what I mean when I say a real square wave has infinite bandwidth. A very rough and basic idea to help here is that a wave can be thought of as a sum of fundamental sine waves. So a square wave is essentially the sum of all the component fundamentals, each fundamental gets sharper and sharper edges of the square. But the only way for the sine wave to have a truly vertical edge is to be infinite frequency, right? And what are the edges of a square wave? Vertical lines. So to keep adding these fundamentals together to achieve a square output, you'd need to add an infinite sum of sines together to make an actually perfect square. Monty touches on this in that video a bit, but it goes pretty quick.