Welcome to healthcare Magic!
You are probably having a local viral/fungal infection
of the penis and it is the local discomfort and pain that is causing the erectile dysfunction
So your problem will resolve once you treat the local infection.
Please get a consult with local physician and get investigations.
A urine routine and culture, and a gram stain and culture/ sensitivity of the glans
swab would be helpful in the diagnosis and treatment.
Wish you a great health!