All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad, sallallaahu ‘alayhi wa sallam, is His Slave and Messenger.
A Muslim is Islamically required to forbid evil according to his ability as Abu Sa’eed Al-Khudri narrated that he heard the Prophet saying: ''Whoever amongst you sees an evil, he should change it with his hand (i.e. physically), if he is unable, then he should change it with his tongue (i.e. verbally) and if he is unable, then he should change it with his heart (by detesting it in his heart) and that is the weakest level of faith." [Muslim]
Changing evil in one’s heart necessitates leaving the place where the evil is being committed and not staying with the people who are committing it. The evil is even greater if it is mocking the religion of Islam as this is disbelief as we clarified in Fatwa 6069. Allaah Says (what means): {And it has already come down to you in the Book [i.e. the Quran] that when you hear the verses of Allaah [recited] they are denied [by them] and ridiculed; so do not sit with them until they enter into another conversation. Indeed, you would then be like them. Indeed, Allaah will gather the hypocrites and disbelievers in Hell all together.} [Quran 4:140]
However, just sitting where the evil is being committed does not necessarily mean being a disbelieve. The interpreters of the Quran interpreted the likeness that is mentioned in the verse to mean emphasizing the greatness of the sin and repelling people from doing it, and that just by sitting with those people who ridicule the verses of Allaah one becomes sinful, but it does not mean that he is like them in disbelief.
Therefore, you do not become a disbeliever [you do not go out of the fold of Islam] as long as your heart is content with belief. However, you are obliged to repent from the sin of sitting with those people while being able to depart from them.
As regards seeking desire by imagination, then this is something Islamically forbidden as it is a means that leads to committing Zina (fornication or adultery); for more benefit, please refer to Fatwa 84496.
Therefore, it is not permissible for a Muslim to resort to it even through the means which you mentioned which is thinking of or reading some Prophetic Ahaadeeth about intercourse and the like; rather the matter may be even worse in this regard. Hence, we advise you to be keen on getting married as soon as possible, otherwise you should observe fasting as per the advice of the Prophet . Also, you should spend your time in what benefits you and avoid anything that would arouse your desire.
Finally, you should know that disbelief and apostasy are not an easy matter in a way that one rules that a Muslim is an apostate or a disbeliever for any minor reason. Even if we presume that a Muslim has committed an act that takes him out of the fold of Islam, then such a Muslim is not ruled to be out of the fold of Islam except if some conditions are met while some impediments do not exist, because if it is confirmed with certainty that someone is a Muslim, then it is not permissible to judge him to be a non-Muslim except with certainty as well, as stated by the scholars . For more benefit, please refer to Fatwa 87963.
Allaah Knows best.