There are several treatments available to control the pain caused by sunburn. Pain relievers, aloe and other cooling gels, as well as cool compresses are all used to treat sunburn. However, there is no way to treat the damage done to the skin, only the pain caused by the sunburn.
The only way to prevent sunburn is to protect the skin. Avoid being in the sun during the parts of the day where the sun is at its hottest. Apply sunscreen to all parts of the skin that will be exposed. Sunscreen should be reapplied every two hours at the least.
American Academy of DermatologySkin Cancer FoundationMayo Clinic