What happened while you were asleep
During sleep, the nervous system moves through stages that can include erections and other automatic genital responses. An ejaculation can happen without conscious choice. You may wake with damp or sticky underwear or bedding, or notice dried semen later.
This is different from bed-wetting: semen is usually whitish or cloudy and sticky when fresh, while urine is more watery and has a familiar urine smell. Sometimes only a small amount is present, especially earlier in puberty.
You may remember a sexual dream, a completely unrelated dream, or no dream at all. The body response does not provide a reliable record of dream content.