Most hernias are not "preventable" as we would like to think. The things that we do that can make us more likely to get a hernia are to be overweight, smoking, chronic coughing, excessive repetitive heavy lifting, poor nutrition, and previous surgery. A large number of hernias are present at birth and those things mentioned above make them worse. Other hernias are the result of previous surgery, a bad trauma or accident, or due to medical conditions that are unable to be prevented (immune and connective tissue disorders).
After surgeries, a period (depending on what type of surgery) of time is often necessary to minimize heavy lifting to allow your incision to heal. Proceeding with activity too soon after surgery can also create hernias.