You might get the bacteria from rubbing your eyes or using old eye makeup.
you might avoid spreading bacteria to other areas in your eye by following good hygiene practices.
This article explains how styes spread and how they can be treated and prevented.

Ocskaymark / iStock / Getty Images
With an internal stye, the pimple-like bump is on the inside of the eyelid.
You may feel it rubbing on the inside of your eye.
An external stye often starts with an infected hair follicle in your eyelashes.
This is usually just a local infection that does not spread to others.
However, some people are more prone to developing a stye.
Hygiene can help to prevent spread.
You should frequently wash your hands.
Also, if you use warm compresses for relief, they should be thrown out after use.
Chalazion or Stye?
While a stye often resolves on its own, it can also become chronic.
There are a variety of possible treatments.
You may want to:
You also can venture to gently massage your affected lid.
Your practitioner can accurately diagnose the condition and begin treatment.
For one thing, this may be a chalazion instead of a stye.
Also, you may inadvertently squeeze the infection into the surrounding tissue, spreading it.
Symptoms include pain and discomfort, itching, light sensitivity, and blurry vision.
Your symptoms may need an accurate diagnosis (they may be due to another cause) and treatment.
American Academy of Ophthalmology.What is the difference between a stye and a chalazion?
Causes, symptoms, treatment.
Department of Health, Victoria State Government.Styes.
American Optometric Association.Hordeolum (stye).
Lindsley K, Nichols JJ, Dickersin K.Non-surgical interventions for acute internal hordeolum.Cochrane Database Syst Rev.
2017 Jan 9;1(1):CD007742.
doi:10.1002/14651858.CD007742.pub4
University of Michigan Medicine,Styes and chalazia,