the most important aspect of racing safely is to constantly anticipate what can go wrong (somebody spinning, missing braking points etc).
to do this, it is best that you (1) have some practice (to know the kart and circuit) before getting into full blown racing situations. highly recommend the chicken wings practice sessions.
the next thing you need to do is to (2) know your competitors. if your competitors are newbies (or the aggressive but error prone sort), do make sure you leave enough room for you to take avoiding actions. avoid contact as best as you can. contact can result in flipping. my own accident came from a contact situation whereby i did not expect somebody to spin on the first corner of the first lap of a race. since then, i tend to give enough room at the start. after all, you don’t win races in the first corner.