Understanding and controlling structural distortions underlying superconductivity in lanthanum cuprates