I scratched my eye when I tried to get my contact out. What can I do to prevent getting infection?

Contacts, abrasion. You should have your eye examined by your eye md. Wearing contact lenses poses certain risks, and infections can occur more frequently if you have an abrasion or scratch. It's best to keep the contact lens out, and you may use artificial tears, but call your eye md so that an antibiotic can be prescribed.
Artificial tears. Most small abrasions never get infected. If your vision is ok and the discomfort minimal, artificial tears and use of glasses instead of contact lenses usually works ok. If in doubt, see an ophthalmologist. Be sure not to continue to wear your lenses.