if you search through the posts on this forum you'll find a few posts on the topic, there's a few explanations, here's the main three trains of thought summarised
1 - in a single sex environment one of the fish will change sex to enable them to reproduce. This is possible in fish (clownfish do it) but as far as I'm aware hasn't been fully proven/relaibly witnessed in swordies or other common livebearers
2 - if you have more thna 1 male 1 of them will be dominant, the others will have suppressed development, when the dominant male is removed from the supressed male the supressed male will grow to become dominant, this includes physical signs like development of a larger gonipdoium
3 - some male's are just late bloomers and are incorrectly identified as females when young, as they get older they are correctly identified.