Biology has two genders (male and female), but German grammar has three genders (male, female and neuter), some African bantu-languages like Swahili even have more than 20 genders, which in this case are no longer called genders but noun classes.
This already should tell you, that biological genders and grammatical genders can not be exactly the same.
Maybe this can help you too:
Grammatical gender is NOT a property of the physical thing you are talking about. It is a property of the word.
Synonyms are different words that are used to name the same physical thing. For example, a car can be in German:
das Auto (neuter)
der Wagen (male)
die Karre (female)
This three words have not exactly the same meaning, but their meanings overlap in a very wide range. (»Karre« is used for shabby cars, »Wagen« for bigger limousines, and »Auto« is used for all cars.) So when you have a shabby old limousine, you can use all three words. But this three words have three different genders.
It is not the vehicle, that you can use to drive along a street, which has a grammatical gender. The words have genders, and they have nothing to do with biological genders. (btw: what might be the biological gender of a car?)