Avoiding sunshine can prevent most types of skin cancer. However one should be realistic about sun avoidance in older adults. The squamous carcinoma on the forehead of an elderly individual probably relates more to occupational and childhood exposure than to exposure in the past few years.
It would be unrealistic for the elderly to adopt a significant sun avoidance strategy as most of the damage has already been done. Also, vitamin D production may be impaired by excessive sun avoidance.
It is very different for young adults. Young adults with a pre-cancerous or cancerous lesion are telling us that they are at significant risk for new skin cancers. Avoiding sunshine is entirely reasonable in this case. Sun avoidance is best undertaken by the timing of outdoor activities so as to avoid the mid-day maximum, wearing appropriate clothing, and lastly, if one can not do the first two, using a sunscreen.
Sunscreens certainly prevent sunburns. It is proven that sunscreens can prevent actinic keratoses and there is good evidence that they will prevent some squamous carcinomas. There is no direct evidence that sunscreens prevent basal cell carcinoma or melanoma, although there is good evidence that sunscreens prevent the development of nevi, which is an important precursor of melanoma.