Theoretical investigation of the defect formation mechanism relevant to nonstoichiometry in hydroxyapatite