Context. Recent observations of the HDO/H2O ratio toward protostars in isolated and clustered environments show an apparent dichotomy, where isolated sources show higher D/H ratios than clustered counterparts. Establishing which physical and chemical processes create this differentiation can provide new insights into the chemical evolution of water during star formation and the chemical diversity during the star formation process and in young planetary systems. Aims. We seek to determine to what degree the local cloud environment influences the D/H ratio of water in the hot corinos toward low-mass protostars and establish which physical and chemical conditions can reproduce the observed HDO/H2O and D2O/HDO ratios in hot corinos. Methods. The evolution of water during star formation is modeled using 3D physicochemical models of a dynamic star-forming environment. The physical evolution during the protostellar collapse is described by tracer particles from a 3D MHD simulation of a molecular cloud region. Each particle trajectory is post-processed using RADMC-3D to calculate the temperature and radiation field. The chemical evolution is simulated using a three-phase grain-surface chemistry model and the results are compared with interferometric observations of H2O, HDO, and D2O in hot corinos toward low-mass protostars. Results. The physicochemical model reproduces the observed HDO/H2O and D2O/HDO ratios in hot corinos, but shows no correlation with cloud environment when similar initial conditions are tested. The observed dichotomy in water D/H ratios requires variation in the initial conditions, for example the duration and temperature of the prestellar phase. Reproducing the observed D/H ratios in hot corinos requires a prestellar phase duration t ~ 1−3 Myr and temperatures in the range T ~ 10−20 K prior to collapse. Furthermore, high cosmic-ray ionization rates (ξH2 ~ 10−15 s−1) appear to be incompatible with the observed D/H ratios toward low-mass protostars. Conclusions. This work demonstrates that the observed differentiation between clustered and isolated protostars stems from differences in the molecular cloud or prestellar core conditions and does not arise during the protostellar collapse itself. The observed D/H ratios for water in hot corinos are consistent with chemical inheritance of water, and no resetting during the protostellar collapse, providing a direct link between the prestellar chemistry and the hot corino.