Oh here we go then
In the case that God is perfectly knowledgeable and all knowing, making EVERYTHING perfectly according to his plans
So when he makes someone, you know that their gender and all the other things about them are just as they should be
If god made mistakes he couldn't be a real God