Like chrismahon says, this type of occurence is often due to an abnormality of the ovaries in a bird. It's not uncommon for it to happen in very elderly females that are no longer capable of breeding, and can be caused by a tumour on the ovary. There are recorded instances of female chickens changing sex and becoming fully functional, fertile males, but it is incredibly rare.