Gastly has a 50/50 gender ratio. Meaning, there’s a 50% chance it’ll be a boy, and 50% of being a girl. The gender of the parent has no effect of the gender of the baby.
You’re likely being confused by the offspring being the same species as the parent when paired with Ditto, or the species being the same as the mother when paired with a different Pokemon.
You’re just getting unlucky. Keep hatching eggs.
Hope this helps!