Where the savings come from
PNG is a container for exactly-compressed pixel data. Nothing is approximated, so every byte it saves comes from removing statistical redundancy.
Each row of pixels is first passed through a filter, chosen per row: none, subtract the pixel to the left, subtract the pixel above, subtract their average, or use a Paeth predictor. The filter output — mostly small differences near zero — is then compressed with deflate, the same algorithm as a zip file. That two-stage design is why a screenshot of flat UI compresses well and a photograph does not: prediction makes smooth areas nearly free, while textured photographic detail stays high-entropy.
Why a PNG can still be huge
A 4000×3000 photograph stored as PNG is typically 10–20 MB. The format is doing its job perfectly; the content simply has too much entropy for a general-purpose compressor. This is not a PNG defect, and no PNG optimiser will rescue it — the fix is a format with a quality dial.
Deflate-level and filter-strategy tuning can shave 5–20% off an existing PNG without touching a pixel. That is what lossless PNG compressors actually do, and it is the honest scope of the "compress PNG" promise.