Masturbation does not cause erectile dysfunction as long as one is not abusive to one's sex organs by overdoing it or doing it in a harmful manner.
There can sometimes be a connection between masturbation and premature ejaculation. This can happen when one masturbates and achieves an orgasm quickly each time. Since the one stimulating is also the one being stimulated, one tends to try to produce the most intense feeling. By these quick orgasms over a period of time, one is training oneself to ejaculate in quick fashion. Instead, try to masturbate in such a way that an orgasm is not achieved so quickly.
I would avoid constantly masturbating to porn. This can affect dopamine in the brain, and could lead to mental erectile dysfunction when you are with a real female. This is because you get less sensitive to real situations, and won't be as stimulated as you are when watching porn. I would stick to mental images and mental scenarios when masturbating to avoid porn addiction which does exist, and keep your brain in the right state to have a healthy normal sex life.