Cavity-Correlated Electron-Nuclear Dynamics from First Principles