In the first case it is a binary executable code, often encrypted.
The difference between EX4 and MQ4 files is the format of the stored code. Files of such type, as well as MQ4 files, contain program code of Expert Advisors, indicators or scripts, which are executed in MetaTrader environment.