Here is Noctua's illustration for fan pins:
The first three wires are the same, in order:
GROUND
+12 VOLTS
RPM SPEED SIGNAL
There are tabs on the fan headers that prevent you from mis-alignment. Either a 3-pin fan or a 4-pin fan can match up with a 4-pin header and the connections will be the same.
The fourth wire on a true PWM 4-pin header is the speed control wire. It uses a PWM signal (series of on/off pulses) to tell the fan how fast to turn.
A 3-pin fan connected to a PWM header will typically turn at full speed since it is connected to +12V and there is no PWM signal to tell it to run slower.
ONE EXCEPTION: many motherboards use 3-pin headers with variable voltage on the +12V pin. In other words, they can control the speed of a 3-pin fan by raising and lowering the 2nd pin between +5V and +12V. Dell uses this configuration for their chassis fan headers, which have automatic speed control.
SECOND EXCEPTION: Some motherboards use a "fake" 4-pin header that does not have a PWM signal on the fourth wire, but a constant +5V signal. A true PWM fan connected to this header will run at 100% speed. A 3-pin fan connected to this header will run at full speed. But, either kind of fan connected to this header can have variable speed if the second pin (the +12V pin) has variable voltage. Many recent high end aftermarket motherboards have this configuration for chassis fan headers.
Honestly, what needs to happen is for everyone to move to true 4-pin PWM headers and fans for all applications.