JPEG
A JPEG is a sequence of marker segments. EXIF sits in an APP1 segment that starts with the text Exif, XMP sits in another APP1 segment with an Adobe namespace, IPTC sits in an APP13 segment of Photoshop resources, and C2PA data is carried in APP11 segments as JUMBF boxes.
PNG
A PNG is a series of chunks. Text such as prompts is stored in tEXt, zTXt and iTXt chunks, EXIF can be stored in an eXIf chunk and C2PA data in a caBX chunk. Many Stable Diffusion tools write generation settings into text chunks.
WebP
WebP uses a RIFF container with separate chunks for EXIF and XMP, and C2PA data can be stored in a dedicated chunk as well.
Why this matters for cleaning
A cleaner that deletes only the segments it knows about can miss a new one. Re-encoding the pixels avoids that problem, because the new file is built from image data alone.