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 is His slave and Messenger.
If you are sure that what you found in your trousers is a semen stain due to having a wet dream and you are not predominantly sure about the time when it happened, then you should consider this as if it happened during the last time you slept in these trousers before you knew about it, so you should perform Ghusl and make up all the prayers that you prayed after that sleep and before performing Ghusl.
Ibn Qudaamah said: “If one sees sperm on his clothes that nobody else sleeps in, then he is obligated to perform Ghusl because ‘Umar and ‘Uthmaan performed Ghusl when they saw sperm on their clothes and because it is not probable that this could be from someone else other than him, so he should make up the prayers which he performed after the most recent time he slept in these clothes unless he sees a sign which proves that it had happened before that, in which case, he should make up the prayers which he performed after the nearest sleep it is probable that it occurred during it.”
Besides, Al-Hattaab from the Maaliki School of jurisprudence, said: “…whoever sees sperm on his clothes, he should make up the prayers from the last time he slept.”
Allaah Knows best.