Realistic modeling of competing phases in complex quantum materials has proven extremely challenging. For example, much of the existing density-functional-theory-based first-principles framework fails in the cuprate superconductors. Various many-body approaches involve generic model Hamiltonians and do not account for the couplings between spin, charge, and lattice. Here, by deploying the recently constructed strongly-constrained-and-appropriately-normed density functional, we show how landscapes of competing stripe and magnetic phases can be addressed on a first-principles basis in YBa2Cu3O6 and YBa2Cu3O7 as archetype cuprate compounds. We invoke no free parameters such as the Hubbard U, which has been the basis of much of the cuprate literature. Lattice degrees of freedom are found to be crucially important in stabilizing the various phases.