Before the Incarnation the Son was pure spirit, just as are the Father and the Holy Spirit. As such, he did not have gender at that time. Only when the Son incarnated as the man Christ Jesus did he become male. The Father and the Holy Spirit remain pure spirit and so do not have biological gender.
For the purpose of revealing himself to us, God has revealed his Trinitarian self primarily in masculine terms because he is the instigator, the first cause; it is he who initiates salvation. It is the Church that is revealed in feminine terms because the Church is the recipient of salvation and the one who nurtures Christians with the graces received from God, Father, Son, and Holy Spirit.