Firstly, try to limit exposure to overly sexualized content. Secondly, work on building self - respect and respect for others. When you see a person as more than just a sexual object, it helps in reducing these kinds of thoughts. Also, practice mindfulness and be aware of your thoughts, and when such a thought comes, consciously shift your focus to something else like your work or studies.
Well, start by surrounding yourself with positive and respectful media. Avoid those materials that might trigger such thoughts. Then, work on your mental and emotional well - being. If you have healthy relationships with friends and family, you are more likely to have positive thoughts. You can also educate yourself about healthy sexuality and gender equality, which can change your perspective and help you avoid such inappropriate thoughts.