How is this simple transistor circuit suppose to work?
There are many bad schematics and pictures online, and these pictures are really bad.

Do not try to make that. You may damage the Arduino board and the transistor.


Even the picture of the BC548 is wrong. The BC548 is always 
called "BC548" and never "BC-548".
The BC548 is not a good choice to drive a motor. It can only
do 100 mA continuous.
The DC barrel socket has plus and minus wrong connected. 
The 12V plus is connected to the Arduino GND. 
That is not okay.
The transistor in the first picture is probably a 
transistor with the pins in BCE order.
A resistor is missing to the base of the transisor.
Because of the missing resistor, the Arduino board
can be damaged.
When the breadboard has a bad connection to GND,
the 12V can go to pin 9 of the Arduino board.


@Dorian, there are no mystical higher alien intelligent thoughts for that schematic. It is obvious a wrong circuit that is meant to drive a motor with PWM using a transistor.

And last but not least:
There are a few different types of computer fans. Some have a capacitor inside and some will only accept a PWM signal to a PWM input.
Are you sure that your fan is able to accept PWM for the 12V power?