A Fritzing cartoon is NOT a schematic.
You seem to completely misunderstand the configuration required for a 4 pin PWM controlled fan.
A 4 pin PWM fan is ALWAYS permanently connected to it's supply rail, in this case Yellow and Black connect to +5V and Ground and are not switched.
The PWM signal is ALWAYS (to meet the spec) driven by either open collector or Open Drain devices, you don't have to pull the signal up to +5V. If this signal is left open circuit the fan runs at full speed.
BLDC computer fans DO NOT need back-emf protection diodes at all on either the fan supply or the PWM signal.
You should connect it like this:
simulate this circuit – Schematic created using CircuitLab
To control the fan speed you need to produce a PWM signal from the raspberry Pi at 18 - 21 kHz.
I assume you already know all the limitations and requirements for the hardware PWM on R'Pi ….if not, perhaps start here.
Update: the Noctua whitepaper pointed to here ….is confusing.
It shows this for the PWM signal:
They then go on to say this:
On the first page they show the short circuit current for the PWM pin as 5mA, which would indicate a 1k Ohm pullup in the fan. In addition per the spec the fan must run at full speed with the PWM pin floating.
The second page where they say they don't recommend an open collector PWM signal makes no sense at all, since they say they meet the Intel spec and must already have a 1k pullup in the fan.
Since the fan already has a pullup to 5V I would suggest it is dangerous to your R'Pi to NOT use the open collector method since the R'Pi I/O is only 3.3V capable. Pulling this above 3.3V could potentially damage an I/O pin.
I would seriously encourage you to use the spec method (Open Collector).