Whether you choose a liquid cooler or an AIO (all-in-one) cooler, you want to install it carefully. Here's an easy guide on how to install a CPU cooler.
Prepare
Use an anti-static wrist strap or touch unpainted metal surfaces to discharge static electricity.
Be sure to check that the cooler is compatible with your motherboard's socket type. Some coolers need specific mounting kits.
CPU coolers have specific instructions, so check the manufacturer's manual.
It might be easier to make sure the motherboard is outside the case for installing a liquid or AIO cooler.
For both cooler types, if there is no pre-applied thermal paste, apply a small amount to the center of the CPU.

Install
If there is a backplate, align the backplate with the holes around the CPU socket and secure it with screws. This is on the back of the motherboard.
For air coolers, mount the cooler by aligning it with the backplate and by screwing it in place, tightening the screws. Use a diagonal pattern when tightening to distribute pressure evenly.
For liquid coolers, you'll need to mount the pump head and radiator. Align the pump head with the CPU and tighten it with screws.
Mount the radiator in the preferred location within the case and tighten with screws.
Once you've got your cooler installed, you'll need to connect the cables. For air coolers, attach the fan cable to the CPU_FAN header.
For liquid coolers, connect the 3-pin cable from the pump to the CPU_FAN header on the motherboard, and the fans on the radiator to the splitter that came with the pump.
Plug the splitter into an available USB port on the motherboard and power it using an available SATA plug.
If your cooler includes an RGB cable, connect it to the appropriate header on the motherboard.
Ensure the pump power cable is connected to a SATA power plug.

Troubleshoot
You may run into some issues after your cooler is installed. Check for visible damage to the cooler fan blades or the heatsink.
If the fan is loud, it could be due to dust buildup. Clean the CPU cooler thoroughly with compressed air.
Inspect the thermal paste on the CPU; if it's old or unevenly applied, reapply a fresh layer.
Make sure the fan is plugged into the correct CPU fan header on the motherboard.
Verify that the power connector to the fan is securely plugged in.
Access the BIOS and check if the fan curve is set correctly.