Both naturally, and by stressing the plant by messing with light, applying acid, etc. During the course of a Female's lifespan it can grow Male pollen sacks and become a Hermaphrodite (hermie) These pollen sacks are slightly different from Male pollen sacks in that (just refer to some of the common genetics you learned back in Highschool biology) instead of producing pollen with both X and Y chromosomes like a normal Male pollen sack which would produce either Male or Female genetics into the seeds it produces, the Female sacks contain only the X chromosomes producing only female seeds (feminized).
Now from my understanding for breeding it is best to use a forced Hermie rather then a natural Hermie to get seeds, because a natural hermie genetically will pass that trait on and you want to produce fem seeds not hermie seeds. I'm not positive on this one either but I believe rather then letting the forced hermie plant pollenate itself, to maintain stability they collect that pollen and apply it to a healthy female.