You can understand polarisation as a resonance if you wish. It's even a common explanation. But keep in mind that the electrons are static in a so-called resonance.
Oxygen attracts electrons not only from the carbonyl carbon, but also a bit from the next atoms. If more atoms bind to the carbonyl (ketone versus aldehyde), the polarisation is easier and stronger. As well, the electron displacement operates over a bigger distance, which also contributes to a bigger dipole moment.