What can cause an insect bite or sting to get infected?

Germs. The bite itself can be sterile, but it opens the skin and any nearby germ can take advantage of the opening to enter and trigger infection. Having soiled skin or scratching the area increases the chances a germ can enter. A thorough immediate cleansing of bite areas will decrease the risk.
Scratching. Scratching an itchy insect bite can cause it to get infected. Keeping both the area of the bite and your hands very clean can help prevent infection.