Full disclosure here: Cats have been part of my life from day one. I've been told that when I was brought home from the hospital after birth, our cat decided to sleep with me in my crib that day. So I may be a little biased about pets and infants.
I think dogs and cats know when Mom is pregnant. Cats and dogs have very sensitive noses, and can detect changes in odors and pheromones. While there aren't studies on pheromone changes during pregnancy, we do have research that hormonal changes can change body odor. I strongly believe our pets pick up on these changes. I have been at labors where I could tell that Mom was getting closer to birth because her pets wanted to be closer to her the nearer she got to birth. Even if pets aren't in the room with Mom for labor and birth, they will hear a baby crying, and will know there has been a change and that they are hearing someone new.
I encourage families to introduce pets to their newborn in the first hours after birth. Just as you would introduce your pet to a guest who comes into your home, you should introduce your pet to the new family member. I do recommend a supervised introduction so parents can help pets to stay calm when they meet baby. I also recommend continued supervision when your pet and baby are together in the future.
After baby is born, expect a few changes in your pet. If you have dogs, they may become very protective and guarding of your baby and may not be as welcoming to visitors as they used to be. With a little time, they will figure out that visitors are okay when a parent is around. Cats may want to sniff baby and that might be all they are interested in doing. Some cats might want to sleep where baby sleeps in the hopes of getting more attention.
Pets are family members too. Letting pets be part of your baby's journey will make life all the richer for both your little one and your pet.