Why this is lossless, and why that is unusual
JPEG, PNG and WebP all keep metadata in discrete container structures — APPn segments, PNG chunks, RIFF chunks — that sit beside the compressed pixel data rather than inside it. Removing metadata therefore means rewriting the container's table of contents and copying the pixel bytes across verbatim. Nothing is decoded, nothing is re-compressed, and the picture is byte-for-byte the same image it was before.
The common shortcut is to draw the photo onto an HTML canvas and export it again. That does remove metadata, because the canvas knows nothing about it, but it also decodes and re-compresses the whole image, losing a little quality every time, and it silently discards transparency and animation along the way. It is the reason a supposedly simple metadata removal can come back looking softer than the original.