You do not need to memorize codec internals to export a good image. Start with what the image contains and where it will be used.
Is it a photograph?
JPEG remains a dependable choice for photographs, especially when broad compatibility matters. WebP and AVIF can often make the same image smaller at a similar visual quality.
Does it need transparency?
For logos, interface graphics, and illustrations with transparent edges, use PNG, WebP, or AVIF. JPEG cannot preserve an alpha channel.
Is it going on the web?
Use the smallest modern format your audience supports, then check the result with your eyes. The right format is the one that preserves the important detail while making the download disappear into the background.
You can compare formats in the JPG compressor, PNG compressor, or WebP compressor before choosing an export.