It is such a scary feeling knowing people in the family have had cerebral palsy. How can we prevent it in our child?

Not inherited. Cerebral palsy is not an inherited disease. It normally results from sort of anoxic injury to the brain, prior to or at the time of birth. That injury will result in different levels of disability.
Good news/bad news. I suppose the good news is that CP is not inherited.Those who approach a pregnancy with knowledge, preparation, good nutrition and prenatal care are most likely to have a good outcome.Bad news/ no guarantee that will prevent it. It is well known that up to 4% of pregnancies end in a surprise of some sort:prematurity, cleft palate, CP etc. Counciling with a geneticist could clarify your risks.
Don't worry. Cerebral palsy isn't something that can be caught or prevented. Many children with cerebral palsy are born prematurely or have some sort of genetic problem. There are a few children who have head trauma when they are under two but this is a rare cause of cerebral palsy.