Defect activity in metal halide perovskites with wide and narrow bandgap