Early in the MS-DOS era, Windows and DOS co-existed, and both had their executable files with the same extension, .exe. So, each Windows application had to start with a small DOS application that prints a message, This program cannot be run in DOS mode (or any similar message). So, when a Windows application gets executed in the DOS environment, the small DOS application at the start of it will get executed and prints this message to the user to run it on Windows environment. In the following figure, you can see the PE file header starting with the DOS program's MZ Header:
Figure 1: Example PE structure
This DOS header starts with MZ and the header ends with a field called e_lfanew, which points to the start of the portable executable header, or PE header.