Within an advanced Langevin-hydrodynamics framework coupled to a hybrid fragmentation-coalescence hadronization model, we study heavy flavor quenching and flow in relativistic heavy-ion collisions. We investigate how the initial heavy quark spectrum, the in-medium energy loss and hadronization mechanisms of heavy quarks, the evolution profile of the pre-equilibrium stage, the medium flow, and the temperature dependence of heavy quark diffusion coefficients influence the suppression and elliptic flow of heavy mesons at the RHIC and the LHC. Our results show that the different modeling of initial conditions, pre-equilibrium evolution, and in-medium interactions can individually yield uncertainties of approximately 10-40% in D meson suppression and flow at a low transverse momentum. We also find that proper combinations of collisional versus radiative energy loss, coalescence versus fragmentation in hadronization, and the inclusion of medium flow are the most important factors for describing the suppression and elliptic flow of heavy mesons.