I’m confused about how Whatsapp backs up data in iPhone In Settings > (my name) > iCloud > iCloud storage: I can see “Whatsapp messenger: 12.8 MB”

In Settings > (my name) > iCloud > iCloud storage > Backups > (My iPhone) > Whatsapp: 86 MB”

What’s the difference between these two?
The first shows you how much data, that has accumulated by using WhatsApp, is currently stored on your phone. That is chats, photos, videos and audio messages that have been send and received.

The second one is the Backup that can be created through WhatsApp->Settings->Chats->Chat Backup. The reason the Backup is larger than your „normal“ app data might be that WhatsApp stored multiple Backups (either from multiple devices or older ones from the same device). Another reason might be that you backed up WhatsApp on an old device or reset your current one after backing up WhatsApp, so your backup contains more data than you accumulated by using WhatsApp after switching/resetting your device.

Again, the first is the data that is currently used by WhatsApp, the second one is the backup and its data is not accessible/used by WhatsApp unless you restore the backup.