If the CPU fan fails to run on boot up the CPU will overheat and the machine will shut down within approx 5 seconds.
Its worth removing the fan from the heat sink and checking for a layer of fluff under the fan. Also dust out the heatsink. In the process you will be disconnecting and reconnecting the fan wires just check the motherboard manual to make sure they are on the correct connections. Its possible they have just worked loose and sometimes don't connect properly. Also make sure no cables can catch on the fan and stop it.
You could also try renewing thermal paste / pad between heatsink and CPU but I don't see how this would give a fan error, just a heat error.
Its possible the fan has developed an intermittent fault and needs replacing
its also possible there is a fault with the motherboard or glitch in the BIOS hence the advice to update BIOS / change motherboard but I would do these as last items.