I know its haram to watch porn and I don't watch it but is it haram to think about people having sex or me having sex with someone? I tried to not think about it but I keep thinking about it so just an simple question is it haram to think about sex?
Thoughts by themselves do not count as hayir (good deeds) or sher (bad deeds). To illustrate for example: its not enough to think about the suras when you are performing the salah. If the imam is not leading the salah you have to move your lips in recitation and be able to hear yourself in recitation.
So idle thoughts don' t count either way. That being said special consideration and caution must be exercised in taming your nefs. An explanation of the nefs and its role is beyond the scope of this answer space, but briefly:
Nefs directly translated means breath but it generally symbolizes all biological needs and desires of the person. Without our nefs we could not survive. Without hunger and thirst we would not strive to make a living to put food and drink on the table Without the desire to have sex with the opposite gender, reproduction would not happen and none of us would exist.
For this, Allah maintains a very powerful and potentially explosive attraction between these opposites. Just like gasoline and oxygen can either cause a destructive explosion or a very useful controlled slow burn to power our vehicles; likewise an unregulated interaction between the genders can lead to explosion (adultery, prostitution, fatherless children, immorality, promiscuity, family corruption, etc) while the regulated and harnessed 'controlled slow burn' will yield the blessed results of peaceful and happy marriage structure and children.
Such volatile mixtures are difficult to control if uncovered. If we think of men as oxygen and women as gasoline, leaving the latter uncovered can lead to explosion; Allah Muhafaza. For this reason, Allah commanded women to cover themselves in public and in front of non-mehram men (Quran 24:31). And men (and women) are commanded to 'lower their gaze'(Quran 24:30).
This 'lower your gaze' applies for today also for media and Internet. It is hard to control yourself when the display of forbidden fruit is just clicks away.
It's when you let your nefs take over your heart and let love of the ephemoral dunya take preference over the love of Allah that may result in sinful action and spiritual corruption.
The nefs has to be kept restrained on a leash of self restraint through faith and taqwa (Quran 91:7-10). This concept of taqwa and self-restraint is alien to the west where it is encouraged to follow your lusts and desires, instant gratification, and let your nefs run wild.
So how do we tame our nefs and keep it on a leash when our senses are bombarded by inappropriate and un-Islamic promiscuity?
The other answers already covered fasting as one technique.
Another effective technique could be neuro-linguistic programming. Please see works on this topic by Anthony Robbins. The way it would work is associating a negative sensation with the sexually provocative image or fantasy. For example associating the smell of very bad breath every time you see the image. After some time and practice you will be disgusted with the image instead of having pleasure fantasies.
Another technique: Each time the sexual fantasy pops into your mind, make dua to Allah to present this person in perfect form and personality in Jennah and for sabr to wait until then. As promised in the Quran the real jewels are in Jennah, in this dunya what looks like jewels are just broken glass and you will likely cut your yourself if you touch or wear them.
As per my understanding it's not haram but it's important to avoid it, because thinking about a wrong stuff is the starting point towards it.
On the other hand If you think about doing good deeds you will get the hasna for it (just for thinking about doing good deeds)
It's the blessing of Allah on us that we are not answerable on our thoughts
In my experience, thinking about sex is bad for you because, this will make you to no longer be able to stop thinking, it is like a smoking, when you start smoking, it is very hard for you to get rid of it, and then what will happen? You will start thinking about something witch you will feel extremely bad and why this? Because the devil is playing with your mind, so better stop doing it before you’ll feel huge regrets.
Haram is the incorrect word to use here.
But, yes, it would be considered sinful to think about immoral things. It would be considered a portion of Zina (adultery):
Allah fixed the very portion of adultery which a man will indulge in. There would be no escape from it. The adultery of the eye is the lustful look and the adultery of the ears is listening to voluptuous (song or talk) and the adultery of the tongue is licentious speech and the adultery of the hand is the lustful grip (embrace) and the adultery of the feet is to walk (to the place) where he intends to commit adultery and the heart yearns and desires which he may or may not put into effect. (Muslim)
Note that some thoughts are simply put there by Shaitan and those are not your fault hence they are not sinful. But the thoughts that one dwells on out of his own weakness are his fault.