Why and how do people get eczema

Many reasons. Too many reasons why people get it. Contact allergens (allergic contact dermatitis), genetic background (atopic dermatitis), dry environment or aging (xerotic eczema), stress (dyshydrotic eczema), stress plus possible yeast infecion (seborrheic dermatitis) are just some of them.
Genetic. Eczema and asthma are common in some families. They are less common among people in rural or less developed areas presumably related to different early programming of immune cells. It is not due to stress or food. It is not contagious.