As you have decided to be unwise and erase your mac you are left with two alternatives,
see below.
So if you have the InstallMacOSX.dmg, you double-click on that to open it to the InstallMacOSX.pkg.
When you have the InstallMacOSX.pkg you double click on that.
An installation window will open, this does not install El Capitan but creates the Install OS X El Capitan.app
which you will find in your Applications folder. Then you would need to create a bootable USB installer
using the instructions here, How to create a bootable installer for macOS – Apple Support
The above instructions can only be carried out on a mac that can run El Capitan, any mac that came preinstalled with
an OS newer than El Capitan will not be able to do this.
The alternative would be to try and re install El Capitan from Apples Recovery Servers,
have you tried that, Restart your mac, press and hold the Command and R keys,
from the Utilities panel that opens click on Reinstall OS X.
Have you tried that yet, if so how did it go.