When you don't want something to happen, you try to "keep it from" happening:
You have to stir it to keep it from getting burnt.
I tried to keep him from leaving, but he was determined to go.
This phrase is used in spoken English. A more formal phrase with a similar meaning is "prevent (something)":
You should apply an antibacterial ointment to the cut to prevent infection.