The interplay between thermodynamics and kinetics in the solid-state synthesis of layered oxides