maybe it's done automatically by Windows on the basis of extensions?
It is a common mis-understanding that Windows (the operating system) does this, but it does not. File extension association has to be looked-up in the registry by whatever is launching the executable, i.e. the shell or application - Windows does not do it for us. See Win32::FetchCommand
In theory the .exe extension is not fixed and can be changed, as can all the other file extensions. It would confuse the hell out of everyone though.