I know that the cores of stars with more than 20 times the mass of the Sun collapse into black holes at the end of the star’s life. However, as far as my understanding goes, stars with cores that become black holes can explode in a supernova. This doesn’t make sense as in order for that event to happen, a star needs to be torn apart by a shockwave created from core bounce. How can this happen for stars more than 20 time the mass of the Sun?
Stars are not torn apart by supernovae, or at least their cores are not$^*$. At the centre of the explosion is a proto-neutron star. Indeed it is the formation of this proto neutron star that drives the explosion.
If the core is massive enough, then the neutron star will be too massive to be supported by any source of pressure and would quickly collapse to a black hole. This might be very likely if the supernova is insufficiently energetic to expel the entire envelope and some of it falls back onto the proto neutron star, causing it to implode.
It also seems likely that many black holes could be formed without a supernova explosion at all. A direct collapse black hole is probably required to produce $>10M_\odot$ black holes.
These possibilities and the observational evidence for them are discussed by Mirabel (2016).
$*$ The exceptions being pair instability supernovae at very high masses, which may set an upper limit to the mass of black hole that can be produced in this way.