Are you supposed to brush a baby's gums even before they have any teeth? Do you start brushing as soon as they're born, or do you wait until they start having teeth? .

Yes. Starting a good brushing routine is a good idea. Use a very soft bristled brush so as not to hurt. Toothpaste is likely not necessary, as the main effect is the mechanical debriding, not the tasty foam from the toothpaste. Many babies may not find toothpaste tasty, and may backfire on you with the acclimation process of brushing.
The. The only reason to brush the gums prior to the teeth being present is if the baby is teething (drooling, irritable).F this soothes the baby's gum then it is perfectly fine as long as you do not brush too hard. When the baby's teeth come in you can use a wash cloth to wipe the tooth or teeth, or use a brush if you like. Make sure it is a brush specifically for the age of your baby. You can also use a dab of Fluoride free toothpaste, which is safe when swallowed in small amounts, .
About 6 months. I wouldn't start as soon as they are born, but about 6 months of age start introducing a small toothbrush into the mouth without any toothpaste. This will get the child accustomed to brushing. As soon as you start seeing teeth, brush them gently twice a day. It is important to get him/her used to brushing as soon as possible and instill the daily habit of brushing.