Understanding the structural properties in two-dimensional halide perovskites under external stimuli