Most people at some point will have an intrusive thought that shocks them by existing and easily push it away. However, this isn't always the case. Some intrusive thoughts can be caused by a form of OCD and it is important that OCD is worked on in therapy as it can be frightening and confusing.
Some men and women have troubling erotic thoughts covering a whole range of offences. That may feel like a confused and scary headspace to be in and it is important to reach out for counselling support as soon as possible to prevent those thoughts manifesting into illegal and criminal behaviour. It is possible to gain control, to understand what is going on, discover boundaries and to adjust the way you relate to your desires.
There are a whole range of sexual offences but I want to point to one in particular because it is of epidemic proprtions and that is on-line sexual offending behaviour towards the underaged. If you are using the internet to image share/ image watch (including illustrations/cartoons) or for sexual chats with or about anyone under the age of 18 (on-line legal age of consent) you are already acting out sexual offending behaviour and it is important to stop these criminal acts and get counselling to prevent further offences taking place. If you have been arrested you can still ask for counselling. I am a trained StopSO therapist and you can read more about StopSO here and their mission to prevent sexual offending. As your therapist I know that this is not the whole of who you are but this behaviour only creates victims and together we can work with the whole of you to stop.