The official, Piriform signed, CCleaner installers for these versions were compromised and installed malware on the host systems.
See here for more details: Cisco's Talos Intelligence Group Blog: CCleanup: A Vast Number of Machines at Risk
See here for more details: Cisco's Talos Intelligence Group Blog: CCleanup: A Vast Number of Machines at Risk