It has been difficult to reconcile the experimental data on the $D^0$ meson nuclear modification factor and elliptic flow in $p-$Pb collisions at LHC energies. Here we study these observables with the string melting version of a multi-phase transport model, which has been improved with the implementation of the Cronin effect (or transverse momentum broadening) and independent fragmentation for charm quarks. Using a strong Cronin effect allows us to provide the first simultaneous description of the $D^0$ meson $R_{\rm pA}$ and $v_2$ data at $p_{\rm T} \leq$ 8 GeV$/c$. The model also provides a reasonable description of the $D^0$ meson $p_{\rm T}$ spectra and the low-$p_{\rm T}$ (below $\sim$ 2 GeV$/c$) charged hadron spectra in $p+p$ and $p-$Pb collisions as well as $R_{\rm pA}$ and $v_2$ in $p-$Pb collisions. We find that both parton scatterings and the Cronin effect
are important for the $D^0$ meson $R_{\rm pA}$, while parton scatterings are mostly responsible for the $D^0$ meson $v_2$. Our results indicate that it is crucial to include the Cronin effect for the simultaneous description of the $D^0$ meson $R_{\rm pA}$ and $v_2$. Since the Cronin effect is expected to grow with the system size, this work implies that the Cronin effect could also be important for heavy hadrons in large systems.