What does formatting an SD card do?

I ran a scan on the SD card using Disk Drill. The preview didn’t show all of my photos, but most of them were there, so I went ahead with recovery and got back the majority of my shots, which is way better than I expected. Next time I’m carrying multiple SD cards with me. If one suddenly asks for formatting, I’ll just switch to another one instead of risking it. Thanks for the help :folded_hands: