Sometimes a plant that is female, that is around no males, that has no access to pollen, and that grows buds normally, can still have seeds.
This is known as a plant going "Hermie", or turning into a "Hermaphrodite".
What this means is that your plant was a female, but becomes both male and female.
This is most common in "Feminized" seeds. Feminized seeds came from a hermie plant, and may hermie all on its own for no reason.
But this shouldn't happen with normal plants, normal plants do have
reasons they will hermie though. These reasons are known as "Stress".
Marijuana is very resilient and hardy, and shouldn't hermie in most conditions. But here are some things that could cause it:
Heavy bend or break
Completely screwed up light cycle
Lots of hairs being pulled
Too much nutrients in the water
Anything that could be considered "Stress" to your plant