>>150045230
>why are machines
In most depictions of Transformers, the Cybertronian race are not actually machines. They're energy lifeforms that use machine bodies to interact with their surroundings.
>sexually dimorphic, do they need sex to reproduce?
Except in very rare cases within the franchise, they're not sexually dimorpic, they're gender-ly dimorphic. No penis or vagina, no sexual reproduction.
Why multiple genders? Most of the time, there is no explanation. They just exist. Even in the few instances where they go into detail why SOME characters/groups are female instead of male (IDW1 stuff, Solus, etc), the root reason for there being different genders is either never revealed, or it's just "idk transformer god made them". You can easily theorize that it's just a sapient, intelligent race going through social evolution. And of course, the real world reason is that having different genders is fun, and the audience isn't just male.
Cybertronian population replenishment depends on which setting you're looking at, and some settings have multiple methods. Usually new energy lifeforms are spit out by the Energy Lifeform God, either directly or though mystical artifacts. Sometimes science is involved in creating or cloning new energy lifeforms. In the earlier media before the energy lifeform concept took stronger hold and Transformers really were just (sapient, intelligent, sociable) machines, there were instances of just building a new guy, or liquid metal budding. There's been more methods other than all the above.
>and who's optimus prime's mom and dad?
Not really applicable given all of the above. Alpha Trion is sometimes seen as Prime's "father", in one setting being the one that rebuilt him from nobody civilian Orion Pax into leader Optimus Prime. In one of the comic runs, everyone has a parental figure that guides them through early life, Optimus's was Codexa.