Optical absorption and emission mechanisms of single defects in hexagonal boron nitride