While the cause is UV exposure, sunburns drive most of the actual risk.[1] so it not technically true that skin cancer is only caused by sunburns, most melanomas come from sunburns. There’s a very linear dose response.
[1] https://pmc.ncbi.nlm.nih.gov/articles/PMC2873840/