Masturbation. is not a cause of infection (unless one engages in dangerous masturbatory practices).
No. I am sorry that somebody told you something this foolish. You're enjoying your body too much when you're missing out on other things that you need to be doing as a young adult -- job, learning, friends, sports. If you are obsessed with erotica like this, get with your personal physician for some talk therapy ;/or medication -- this is fairly easy to treat. Best wishes.