Just like all cancers, we just don't know enough about Melanoma to be certain about any part of it - including the causes of Melanoma. My husband was an avid fisherman, owning our own boat for offshore fishing. We live in the country, and stay out doors quite a bit with maintaining such a life style. However - his Melanoma was located on the underside of his arm. A place there rarely sees the sun. He also has three additional moles where they are watching closely - those are located on his torso. My husband NEVER EVER goes anywhere with out a shirt...EVER. Therefore - I don't think it was the sun that caused the Melanoma. Does the sun increase the chances of Melanoma? Yes. If you never go out in the sun are you safe from Melanoma? No.
My husband has many family members who have died from various cancers. Could cancer be a genetic factor? Could be. Nothing is ever certain about cancer, nothing.
Having said that - your survival rate increases dramatically when Melanoma is caught early. Continue being vigilant about check ups. Use sun screen. And did I say be vigilant about check ups? If you are concerned about something new, get it checked. Make regular appointments with a dermatologist - not a primary care physician.