Perovskite photovoltaics have made extraordinary progress in power conversion efficiency (PCE) and stability owing to process and formulation development. Perovskite cell performance benefits from the addition of alkali metal cations, such as cesium (Cs+) and potassium (K+) in mixed ion systems, but the underlying reasons are not fully understood. Here, we study the solidification of perovskite layers incorporating 5, 10, to 20% of Cs+ and K+ using in situ grazing incidence wide-angle X-ray scattering. We found that K+-doped solutions yield non-perovskite 4H phase rather than the 3C perovskite phase. For Cs+-doped formulations, both 4H and 3C phases are present at 5% Cs+, while the 3C perovskite phase forms in 10% Cs+-doped formulations, with undesirable halide segregation occurring at 20% Cs+. Post-deposition thermal annealing converts the intermediate 4H phase to the desirable 3C perovskite phase. Importantly, perovskite layers containing 5% of Cs+ or K+ exhibit reduced concentration of trap states, enhanced carrier mobility and lifetime. By carefully adjusting the Cs+ or K+ concentration to 5%, we demonstrate perovskite cells with a ≈5% higher average PCE than cells utilizing a higher cation concentrations. The study provides unique insights into the crystallization pathways towards perovskite phase engineering and improved cell performance.