I am 20 years old male 3 years back I attended the self sex this bad habit continues more than two years, so now I’m afraid. So my doubt is will this bad habit cause any problem in my marriage sex life? And it causes any problem in my penis and sperm?

First of all, remove the guilt that it is bad. It is normal physiological urge. As such masturbation is not harmful but sometimes (particularly in daily masturbators) it may result into premature ejaculation (early discharge). It does not cause any problem in penis or sperms.