Hey, any kind of stress can trigger plant goes hermafrodit ,too cold or too hot ,too much low stress or high stress training ,for me it was caused by too much defoliation in flower and I get few seeds ,and indeeed if you have any male around the pollen will do it’s thing, just try to avoid any kind of stress to your plant 👍🏼.