According to the American Academy of Dermatology, some people are more likely to get nail fungus than others (https://www.aad.org/public/diseases/contagious-skin-diseases/nail-fungus#causes). There are several factors that increase the chances of developing a fungal nail infection.
Nail fungus is more common in old age and less common in children.
Living in a hot and humid area
The risk of developing nail fungus will increase if you have one or more of the following:
Poor circulation due to Cancer, Diabetes, or other factors
Weak immune system due to HIV or other diseases
History of having a Nail fungus
A family member who has a nail fungus
Way of living
The risk of developing nail fungus will increase if you:
Spent time in water frequently
Walk barefoot in public places such as pool or locker room
Wear ill-fitted shoes
Wear plastic gloves
In summary, you are more likely to get a fungal nail infection when you have your nails exposure to the hot and humid environment. Also, if you have a weak immune system and poor circulation, the fungi are prone to develop until the point where you get a fungal nail infection.
Try to keep your nails dry and clean. If you get a fungal infection, contact your doctor or podiatrist before it spreads out and damages other nails.