Stellar mergers are responsible for a wide variety of phenomena such as rejuvenated blue stragglers, highly magnetised stars, spectacular transients, iconic nebulae, and stars with peculiar surface chemical abundances and rotation rates. Before stars merge, they enter a contact phase. Here, we investigate which initial binary-star configurations lead to contact and classical common-envelope (CE) phases and assess the likelihood of a subsequent merger. To this end, we computed a grid of about 6000 detailed 1D binary evolution models with initial component masses of 0.5 − 20.0 M⊙ at solar metallicity. Both components were evolved, and rotation and tides were taken into account. We identified five mechanisms that lead to contact and mergers: runaway mass transfer, mass loss through the outer Lagrange point L2, expansion of the accretor, orbital decay because of tides, and non-conservative mass transfer. At least 40% of mass-transferring binaries with initial primary-star masses of 5 − 20 M⊙ evolve into a contact phase; > 12% and > 19% likely merge and evolve into a CE phase, respectively. Because of the non-conservative mass transfer in our models, classical CE evolution from late Case-B and Case-C binaries is only found for initial mass ratios qi < 0.15 − 0.35. For larger mass ratios, we find stable mass transfer. In early Case-B binaries, contact occurs for initial mass ratios qi < 0.15 − 0.35, while in Case-A mass transfer, this is the case for all qi in binaries with the initially closest orbits and qi < 0.35 for initially wider binaries. Our models predict that most Case-A binaries with mass ratios of q < 0.5 upon contact mainly get into contact because of runaway mass transfer and accretor expansion on a thermal timescale, with subsequent L2-overflow in more than half of the cases. Thus, these binaries likely merge quickly after establishing contact or remain in contact only for a thermal timescale. On the contrary, Case-A contact binaries with higher mass ratios form through accretor expansion on a nuclear timescale and can thus give rise to long-lived contact phases before a possible merger. Observationally, massive contact binaries are almost exclusively found with mass ratios q > 0.5, confirming our model expectations. Because of non-conservative mass transfer with mass transfer efficiencies of 15 − 65%, 5 − 25%, and 25 − 50% in Case-A, -B, and -C mass transfer, respectively (for primary-star masses above 3 M⊙), our contact, merger, and classical CE incidence rates are conservative lower limits. With more conservative mass transfer, these incidences would increase. Moreover, in most binaries, the non-accreted mass cannot be ejected, raising the question of the further evolution of such systems. The non-accreted mass may settle into circumstellar and circumbinary disks, but could also lead to further contact systems and mergers. Overall, contact binaries are a frequent and fascinating result of binary mass transfer of which the exact outcomes still remain to be understood and explored further.