Does masturbation affect fertility in men?

It does not. I'm very sorry that somebody told you this. The "scientific basis" is the discovery that sperm counts per unit volume of semen are lower if a man ejaculates frequently. The reason is that more fluid is reabsorbed during abstinence. There is nothing "spiritual" about telling or believing untruths about your body; growing up is difficult enough as it is. Think about the girl you'll marry. Cheers.