We present various properties of the production of the $X(3872)$ and $\ensuremath{\psi}(2S)$ states based on $10.4\text{ }\text{ }{\mathrm{fb}}^{\ensuremath{-}1}$ collected by the D0 experiment in Tevatron $p\overline{p}$ collisions at $\sqrt{s}=1.96\text{ }\text{ }\mathrm{TeV}$. For both states, we measure the nonprompt fraction ${f}_{NP}$ of the inclusive production rate due to decays of $b$-flavored hadrons. We find the ${f}_{NP}$ values systematically below those obtained at the LHC. The ${f}_{NP}$ fraction for $\ensuremath{\psi}(2S)$ increases with transverse momentum, whereas for the $X(3872)$ it is constant within large uncertainties, in agreement with the LHC results. The ratio of prompt to nonprompt $\ensuremath{\psi}(2S)$ production, $(1\ensuremath{-}{f}_{NP})/{f}_{NP}$, decreases only slightly going from the Tevatron to the LHC, but for the $X(3872)$, this ratio decreases by a factor of about 3. We test the soft-pion signature of the $X(3872)$ modeled as a weakly bound charm-meson pair by studying the production of the $X(3872)$ as a function of the kinetic energy of the $X(3872)$ and the pion in the $X(3872)\ensuremath{\pi}$ center-of-mass frame. For a subsample consistent with prompt production, the results are incompatible with a strong enhancement in the production of the $X(3872)$ at the small kinetic energy of the $X(3872)$ and the $\ensuremath{\pi}$ in the $X(3872)\ensuremath{\pi}$ center-of-mass frame expected for the $X+\mathrm{soft}$-pion production mechanism. For events consistent with being due to decays of $b$ hadrons, there is no significant evidence for the soft-pion effect, but its presence at the level expected for the binding energy of 0.17 MeV and the momentum scale $\mathrm{\ensuremath{\Lambda}}=M(\ensuremath{\pi})$ is not ruled out.