In more detail
A file begins with the bytes MZ (4D 5A), and a pointer near the start leads to the signature PE\0\0 (50 45 00 00). Sections such as .text (code), .data and .rsrc (resources) each have a size and an entropy that analysts inspect. See the Executable Forensics.