The cause of a stye is usually a bacterial infection by Staphylococcus aureus.The internal ones are due to infection of the meibomian gland while the external ones are due to an infection of the gland of Zeis. A chalazionon the other hand is a blocked oil gland without infection. They are typically in the middle of the eyelid and non painful.
Often a stye will go away without any specific treatment in a few days or weeks. Recommendations to speed improvement include warm compresses. Occasionally antibiotic eye ointment may be recommended. While these measures are often recommended evidence to support them is poor. The frequency at which they occur is unclear. They may happen at any age.