Context. The isomerism of molecules in the interstellar medium and the mechanisms behind it are essential questions in the chemistry of organic molecules in space. In particular, for the simple formic and thioformic acids, the low temperatures found in molecular clouds indicate that cis-trans isomerization in the gas-phase must be impeded. Reactions happening on top of interstellar dust grains may explain the isomer interconversion at low temperatures. Aims. We studied the isomerization processes of formic and thioformic acid susceptible to happen on the surface of interstellar dust grains and initiated by H abstraction reactions. Similarly, deuterium enrichment of the acids can occur by the same mechanism. Our objective is to shed light on both topics to increase our understanding of key precursors of organic molecules in space. Methods. We determined the rate constants for the H abstraction reactions as well as the binding energies for the acids on water ice using ab-initio calculations and the instanton method for calculating the rate constants, including quantum tunneling. In addition, we tested the viability of the deuteration of formic acid with tailored experiments and looked for it on the L1544 source. Results. For formic acid, there is a clear dependence of the H abstraction reactions on the isomer of the reactant, with rate constants at ∼50 K that differ by 5 orders of magnitude. Correspondingly, we did not observe the trans-cis reaction in our experiments. In the case of thioformic acid, a very similar cis-trans reactivity is found for abstraction reactions at the thiol (-SH) group in contrast to a preferential reactivity found when abstractions take place at the -CH moiety. We found comparable binding energies for both isomers with average binding energies of around −6200 K and −3100 K for formic and thioformic acid, respectively. Our binding energy calculations show that the reactions are precluded for specific orientations, affecting the overall isomerization rate. For H abstractions initiated by deuterium atoms, we found very similar trends, with kinetic isotope effects varying in most cases between 13 and 20. Conclusions. Our results support the cis-trans interconversion of cis-formic acid on dust grains, suggesting that such an acid should not withstand the conditions found on these objects. On the other hand, the trans isomer is very resilient. Both isomers of thioformic acid are much more reactive. Non-trivial chemistry operates behind the apparent excess of its trans isomer found in cold molecular clouds and star-forming regions due to a subtle combination of preferential reactivity and binding with the surface. In the light of our results, all the deuterated counterparts of thioformic acid are viable molecules to be present on the ISM. In contrast, only the trans isomer of deuterated formic acid is expected, for which we provide upper bounds of detection. With the mechanisms presented in this paper, other mechanisms must be at play to explain the tiny fraction of cis-formic acid observed in i...