Nobody knows the causes of skin cancer. But there are certain factors that make it more likely. The main risk factor is over-exposure to sunlight. Other risk factors:you have fair skin that burns easily, have a lot of moles(more than 100), have red or fair hair and blue or green eyes, have lots of freckles, have certain skin conditions(eg scarring from burns or skin ulcers), have had repeated sunburn, especially during childhood, have close relatives who have had skin cancer, use a sunbed, work outdoors, smoke, have a weakened immune system(eg if you have HIV/AIDS, or are taking medicines that suppress your immune system); and rarely, if you have been exposed to certain chemicals. Age is also a factor as NMSCs are more common in people over 60 and rare in children under 14.
Attribution: BUPA