Using resonant X-ray diffraction and Raman spectroscopy, we study charge correlations and lattice dynamics in two model cuprates, HgBa$_{2}$CuO$_{4+delta}$ and HgBa$_{2}$CaCu$_{2}$O$_{6+delta}$. We observe a maximum of the characteristic charge order temperature around the same hole concentration ($p approx 0.09$) in both compounds, and concomitant pronounced anomalies in the lattice dynamics that involve the motion of atoms in and/or adjacent to the CuO$_2$ layers. These anomalies are already present at room temperature, and therefore precede the formation of the static charge correlations, and we attribute them to an instability of the CuO$_2$ layers. Our finding implies that the charge order in the cuprates is an emergent phenomenon, driven by a fundamental variation in both lattice and electronic properties as a function of doping.