The CPU Die produces heat that today is thermally transferred to the heat spreader on the CPU, the heat spreader does what it implies it spreads the heat load over a larger surface.
There are various types of heat sinks, standard fin, heat pipe, and water blocks, these devices are used to conduct the heat from the heat spreader to a dissipation point either with air or water cooling.
Since air itself is a poor heat conductor thermal compound is used to fill the air gaps between the heat spreader and the heat sink, to conduct the heat transfer.
An air cooled heat sink transfers the heat to the cooling fins and the fan forces ambient air over the fins picking up the heat and flowing it away from the heat source.
A heat pipe air cooler works the same but the heat pipes wick a hot thermal liquid picked up at the base of the cooler to the tips of the pipes where the cooling fins are located, and the fan delivers the airflow to cool the fins, thus cooling the heat pipes and the thermal liquid returns to the base to repeat the cooling transfer.
In a water cooling setup it's a team effort the liquid flowing through the water block, (powered by the water pump), transfers the heated water to a radiator and the fans in this regard cool the radiator fins, thus cooling the water inside the radiator.