Firstly I want to assure you that you will be alright. Don't worry.
From what ever you have written it is quite clear to me that you have something called OCD I.e obsessive compulsive disorder. DON'T BE SCARED when I say this.
It is a very common psychological disorder in which the person is obsessed with the same thought all the time. It could be same thought or same action also. Repeatedly watching sex movies, masturbation, etc are some of its symptoms.
It is often associated with anxiety and depression. It runs in families.
It is a treatable disorder and one can lead a normal life later.
Next Steps
Be confident, you will be fine.
Health Tips
Homeopathic treatment is excellent for psychological disorders. You can contact me if you are interested.
Exercise regularly and do meditation.