Which format should you actually use
JPEG is the safe currency. Every piece of software made in the last thirty years opens it, it is small, and it is the right choice for photographs going anywhere you do not control. It cannot store transparency.
PNG is lossless and keeps transparency, which makes it correct for logos, icons, screenshots containing text, and anything you will edit repeatedly. The cost is size — often several times a JPEG of the same picture.
WebP is the modern web default: roughly 30 percent smaller than JPEG at similar quality, with transparency support. Every current browser reads it; plenty of desktop and print software still does not.
AVIF compresses better still and is the least supported outside browsers. Good for websites, awkward everywhere else.
HEIC is what iPhones produce. Efficient, and readable by almost nothing outside Apple's ecosystem, which is why converting it is so common.
GIF holds 256 colours and animation. BMP is essentially uncompressed and enormous. Both are legacy formats you convert away from rather than to.
The one rule worth remembering
Every conversion between two lossy formats — JPEG, WebP, AVIF and HEIC are all lossy — discards a little more detail, and that loss is permanent. Convert from your original file whenever you still have it, rather than converting a converted copy. Converting once is nearly invisible; converting the same image back and forth several times is not.