When you say CPU fan are talking about something like this:
Or does it loke more like this:
That is, are you talking about just the fan or the fan + heatsink assembly?
I'm guessing you're talking about the fan + heat sink but I want to be sure.
If I'm right, the stuff between the heat sink and the CPU is called thermal paste. It's job is to help move heat from the CPU to the heat sink. While it might be able to stick the heat sink to the CPU, you're not supposed to rely on it for that. The heat sink needs to be fastened to the motherboard. Honestly I'm surprised it worked at all in an upright position.
By the way, if you need new thermal paste, look for
Arctic Silver, thats a pretty good brand. They also have
excellent instructions on how to apply it properly (and how to remove old thermal paste).
But again, do not rely on thermal paste to "glue" the heat sink to the CPU, you will need to fasten it properly.