Sine and cosines and their related exponentials form a nice set of orthogonal functions. In your quantum well case, that fits the boundary conditions nicely.
If you had an optical fiber, or a nanowire quantum well, and you had a cylindrical geometry, when you work through the differential equation and looked for a nice set of orthogonal functions you would find that Bessel functions have a oscillatory and exponential like functions that would fit the boundary conditions.
In both cases you would find that the Eigen value would be related to the frequency(or wavelength)and the geometry. The width the well or the radius of the nano wire.
Same for spheres: spherical harmonics and Legendre functions depending on the partial differential equation you want to solve.
You can also look at Fourier series works . Usually you make them up out of sines and cosines, so a sine or cosine is more fundamental than a square wave. Since they are orthogonal functions you can also normalize them easily. A square wave can be described by the Fourier series. However you can general the Fourier series to use other functions, but sines and cosines are often convenient since people think about waves in terms of sines and cosines.