Canon EF mount is 44mm. Pentax K is 45.5mm
So you've got just 1.5mm
It's close but it's just enough. One other reason why it works, is that the EF mount has quite large diameter so the PK fits nicely inside the EF mount.
So, for example, you won't find an EF to 4/3 mount adapter because the EF's large diameter won't allow the lens to fit inside the 4/3 mount diameter. (and I'd also say it's pointless because there no aperture ring on the EF lenses, although I've seen an EF to micro 4/3 adapter!!!)