Understanding Fourier, signals and spectrum analyzer
Others have posted some very nice visual explanatory tools, yet to me, they seem to be a step or two down the road from the absolute basics. Let me offer my own super-basic explanation: 

First, try to multiply two sinewaves, over some period of time, say two or three periods of your slower sinewave. Take a piece of paper and a pencil if you will, but a couple discrete-time samples calculated in Excel can also produce a valid chart. Start by simple examples, such as: two sine waves of unity amplitude, same frequency, same phase, centered around 0 amplitude (= no DC offset). You need to multiply the instantaneous scalar value at every point in time to produce the resulting third wave (= multiplication product).

Unfortunately I don't have a visual software tool to facilitate this super-simple mental experiment... A quick search through Google Images has revealed  two static charts here.

Further points to consider:

If you multiply two negative numbers (scalars), you get a positive number (scalar). For the result to be negative, you need to multiply a positive and a negative number. Therefore, if you multiply two identical sine waves, the product wave lives in positive numbers only, plus the zero. (And, the product happens to be a pure sine wave of double frequency and DC-shifted, but that doesn't seem to be of much concern here, don't let it mess up your mind.)

To produce some negative values in your "multiplication product" wave, you need a phase shift, or waves of two different frequencies. Watch the individual quadrants expand into the negative values.

Try multiplying two sinewaves with only somewhat different frequencies, say 20% difference, over maybe 10 periods of the slower signal. The link points to an article on superhets, but the sinewave multiplication applies equally, and the waveform plot is very nice (only we could use a zero axis for the "product" waveform in our topic).

Next, guess what happens if you integrate the product wave in time. This is a key operation: your spectral line (the output "amplitude" for a single frequency) is your multiplication product wave, integrated over a given time window.

Note that if you multiply your "input signal" by a sinewave (your "probe"), the product wave (and its integral) will reflect the phase of the probe relative to the input. E.g., for two pure identical sinewaves, that are 90 degrees out of phase, the multiplication product wave will be centered around zero, and its integral will therefore be 0. As if the input wave "was not there"!  

To capture an input sinewave regardless of its phase, you need to perform the "waveform multiplication" operation twice for each frequency of interest (probe), using sine and cosine waves for a "probe". Note that sine and cosine are just identical waves, only 90 degrees phase-shifted. Thus, when the sine multiple produces a zero "integrated amplitude", the cosine multiple produces your desired full value. For phases other than 90 degrees, just consider the two output values as a complex number, which you can use as such, or you can calculate its Pythagorean absolute value if you're not interested in the phase.

The Fourier transform means, that you do this "wave multiplication followed by integration" for a certain range of frequencies. As for the range of frequencies considered, it can be discrete or continuous, bounded or unlimited... In theory, an arbitrary continuous signal over a bounded time period produces a continuous spectral image over an infinite range of frequencies. In practice, FT is calculated over a bounded time period of discrete time domain samples, to produce a bounded range of discrete frequency samples. You only have a finite resolution in time and amplitude, and a finite amount of number-crunching horsepower.

An arbitrary input signal (including a square wave) simply "rings" different "sinusoidal probes" with a different phase angle and intensity. And, a square wave rings a series of harmonic sinewaves. A pefect sawtooth does something similar. Essentially any sharp corners in the signal produce a series of harmonics, because you need a series of sine waves of different frequencies to sum up to a half-decent sharp corner in the time domain.

As a homework, but you may have been wondering about this already: think about the effect of window size (temporal, in the input signal) on the result, considering a pure sinewave for input and a pure sinewave for output. And, what happens if the window size gradually decreases relative to the period of your "probe" frequency and of your input waveform.