Defect engineering in SrTiO3 crystals plays a pivotal role in achieving efficient overall solar water splitting, as evidenced by the influence of Al3+ ions. However, the uneven structural relaxation caused by Al3+ ions has been overlooked, significantly affecting the defect state and catalytic activity. When an Al2O3 crucible is used, optimizing this defect engineering presents a significant challenge. In this study, we introduced In3+ into the SrTiO3 crystal to achieve favorable photocatalytic performance. Notably, In3+ stabilizes at the B sites of SrTiO3, outcompeting Al3+, demonstrating a bifunctional effect by simultaneously regulating the concentration of defect charges and mitigating the negative impact of Al3+ on structural relaxation, leading to shallow-state defects. Additionally, the incorporation of In3+ ions effectively prevents the precipitation of perovskite Sr2+. Carrier behavior studies and density functional theory (DFT) calculations provide substantial evidence of the underlying modulating mechanism. Consequently, the optimized In3+-doped SrTiO3 exhibits impressive gas evolution rates of 1.40 mmol·h-1 H2 and 0.69 mmol·h-1 O2 under full-spectrum light irradiation, corresponding to a promising apparent quantum yield (AQY) of 82.36% at 365 nm and a solar-to-hydrogen (STH) efficiency of 0.54%. Such enhanced activity could be attributed to the effective incorporation of In3+ ions, which improves the structural stability of the perovskite SrTiO3 lattice.