I can understand that you feel confused about your sexuality. You are worried about your thoughts and fantasies. You also wrote you watch pornography at least 4 times a week and you masturbate yourself each time you watch porn. Firstly, I dont think there is a problem about watching porn and masturbate 4, 5 or 6 times a week if you dont have problems because of it. Many young men do it. Do you also have sexual relations with your girlfriend? Do you masturbate because you are not satisfied with her or just because you like it?
In your message, you writed that in porn, the penis turns you on but only when it penetrates women. Are you worried about it? How it makes you feel? Personally, I believe it is normal. What turn you on about a penis with a woman? The sexual power and excitation the erection represents? Your own sexuality ? Personally, do you want to have sex with another man?
Finally, you writed you are jealous but you masturbate when thinking about your girlfriend having sex with gay men. Then, you feel angry about these thoughts. Do you know several men and women having the fantasy of seing their partner having sex with another man or women or having sex with their partner and someone else. What do you think of having sex with your girlfriend and another man? Are you excited about it or it doesn’t turn you on?
Your thoughts are not bad, and it is quite difficult to stop having them. Another possibility you have is to accept them as a part of yourself and your sexuality.