Most of STM32 come in relatively big packages. Not that there are physically big - in most families, there are those tiny Chip-Scale (WLCSP) packages available; however, these are not very manufacturing-friendly and fit only for mass production. For applications, where pin count is not an issue, packages like QFP-24 are TSSOP-20 are more in demand.
While ST does produce these for some families, they contain the same physical chip as their 64+ pin counterparts, except that most of the pins are simply not brought out to the package. The reason is cost - in modern semiconductor production, a set of masks easily goes to $1M+ and it may take several respins to get a particular chip right; adding to this the inevitable development and testing costs leaves the manufacturer with significant NRE per design. Packaging them to different pin count packages to widen the portfolio, thus perfectly makes sense.
One of the drawbacks of this approach is, that sometimes it's necessary to make tradeoffs. Omitted pins means also unusable peripherals, given the limited GPIO AF matrix.
In some cases, ST solved this by a feature called remapping. Particularly, in STM32F042, USB (and CAN) pins are brought out to PA11/PA12, which are not available on the TSSOP20 and QFN28 (UFQFPN28) packages. However, after setting SYSCFG_CFGR1.PA11_PA12_RMP, the PA9/PA10 pins are replaced by PA11/PA12, making USB or CAN available again.
Why this was not solved by mapping in the "regular" GPIO matrix, I don't know.