OK first masterbating is a bad thing to do, as it gives your p***s the wrong training, but ejeculation through wet dreams is something us men have to put up with, and I cant think of anyway of containing it apart form staying up all night, he real problem is explaining it to your mum or wife that it just keeps happening and that you were not masterbating.
But if you think about it there should be a trigger in you mind just be for you ejeculate, it should just wake you up a bit before it happens, hit that bit and you should stop yourself from ejeculating.
But wet dreams is being a man.
Good Luck
Wet dreams are common and will not harm you in any way. Whomever told you that ejaculating frequently is a bad thing is mistaken. Wet dreams will not lead to future infertility. They just mean you are hormonally normal.