Why, in a passive circuit with a sinusoidal input, do all voltages and currents have the same sinusoidal behavior as the input?

I've been pouring my brains out and eventually I've found a nice mathematical approach to prove this and decided to answer my own question. In such a circuit, solving for any voltage/current across/through any component (I'll call that \$f\$) would always lead you to construct a differential equation that is always linear, with constant coefficients (due to linear properties of passive components) and non-homogeneous (due to the sinusoidal input). Such a differential equation will always take this form: $$a\frac{d^nf}{dt^n}+b\frac{d^{n-1}f}{dt^{n-1}}+...+j\frac{df}{dt}+kf=C\sin{(\omega t+\theta)}$$ where \$a...k\$ are constants (combinations of inductance, resistance, etc.), \$n\$ is the order of the differential equation (which reflects the number of energy storage elements in the circuit), and \$C\sin{(\omega t+\theta)}\$ is a generalized sinusoidal function that describes the input. A general solution to this differential equation will always take this form: $$f=\text{(general homogeneous solution)}+\text{(particular solution)}$$ where the particular solution \$=A\sin{(\omega t+\theta)}+B\cos{(\omega t+\theta)}\$ which is a sinusoidal function of the same frequency! Now, in AC circuit analysis, we are always looking at the circuit in steady state, when the homogeneous solution approaches zero (which inevitably happens because of resistances in the circuit).

This is only true for LTI (Linear Time-Invariant) circuits. If you have a non-ideal component (and they all are to one degree or another) you will see harmonics of the input frequency in the output. Inductors tend to be the worst of the lot, but all passive parts have such behavior. For example, capacitors can exhibit strong voltage coefficient and are not time invariant because of dielectric absorption.

For a straightforward (assuming roughly 2nd year University math knowledge) mathematical proof you can read these Berkeley course (EECS20N: Signals and Systems) notes. You can download the entire text here.

It happens because a sinewave is just one line in the frequency spectrum and no matter what you do with it using a linear filter or amplifier, all that happens is that the phase or amplitude shifts.

If it were a square wave (infinite harmonics) then applying a filter would attenuate or accenuate some frequencies more than others and the square wave would lose its recognizable square shape.

Square wave harmonics: -

enter image description here

Gif source