Surface-mediated mechanisms for defect engineering in zinc oxide