Boundaries determine the formation energies of lattice defects in two-dimensional buckled materials