All perfect praise be to Allah, The Lord of the worlds. I testify that there is none worthy of worship except Allah and that Muhammad is His slave and Messenger.
First of all, you have to strive against these intrusive thoughts and try to get rid of them. You should know that these thoughts do not affect you and do not undermine your faith as long as you have no control over them. Also, their treatment is easy, Allah willing. You should seek the help of Allah and try to repel them and seek the help of trustworthy doctors. For more benefit, please refer to fatwa 84232.
As regards Mathy, it invalidates ablution. When you have Mathy discharges, you have to wash your private parts and perform ablution for the prayer.
If these discharges are continuous, in a way that you do not find enough time sufficient to perform ablution and the prayer, then you should perform ablution after the time of the prayer begins and then pray the obligatory prayer and whatever supererogatory prayers (Nafl) you wish to perform until the time of this prayer ends [which means until the beginning of the time of the next prayer]. For more benefit, please refer to fatwa 286264.
As regards the prayers that you had prayed without a new ablution after having had those discharges, then there is a difference of opinion among the scholars on the obligation of making up for them. The view chosen by Shaykh Ibn Taymiyyah is that you are not obliged to make up for them due to your ignorance of the ruling. Please, refer to fatwa 344401. There is no harm on you if you choose to act upon this view even though making up for them is better in order to be on the safe side.
If you doubt whether these discharges are Mathy or normal vaginal discharges, then, according to the view that we hold here at Islamweb, you may choose either of them and follow the relevant ruling.
Allah knows best.