In more detail
A PNG file is a signature followed by chunks, each with a length, a four-letter type, data and a CRC-32 Checksum. IHDR gives width, height, bit depth and colour type; IDAT holds the pixels compressed with DEFLATE; IEND closes the file. Images can be greyscale, palette-based (up to 256 colours, often called PNG-8) or full RGB, with or without an alpha channel, at up to 16 bits per channel.
Why it matters
PNG keeps every pixel exactly, which is ideal for screenshots, logos, diagrams and anything that will be edited again, but photos make very large files; use JPEG or WebP for those. The compression level only trades speed for size: it never lowers quality. Optimisers and palette reduction can often shrink a PNG considerably without any visible change.
Example
A single opaque red pixel saved as an RGBA PNG is 70 bytes. Its first 26 bytes:
89 50 4E 47 0D 0A 1A 0A signature
00 00 00 0D 49 48 44 52 length 13, "IHDR"
00 00 00 01 00 00 00 01 08 06 width 1, height 1, 8-bit, RGBA
The signature spells PNG after one non-text byte, followed by a CR LF, a Ctrl-Z and a LF, which reveal transfers that alter line endings.