How PNG compression works here
JPG and WebP are re-encoded at the quality you pick; 80% is the sweet spot where files shrink by well over half and nobody can tell. PNG has two modes: the palette mode reduces the image to up to 256 well-chosen colours with optional dithering, which is what tools like TinyPNG do, and the lossless mode keeps every pixel but repacks the file with the best PNG filters and maximum compression.