Tunnelling plays a crucial role in the low-temperature chemistry in the interstellar medium (ISM), in particular for reactions involving hydrogen atoms. Using harmonic quantum transition state theory we studied reaction rates down to 20 K including tunnelling effects for the gas phase reaction of formaldehyde with hydrogen atoms, paying particular attention to isotope effects. Hydrogen atoms can either add to formaldehyde, yielding the methoxy radical which is ultimately hydrogenated to form methanol, or they can subtract a hydrogen atom, which could provide a route for deuterium enrichment. The isotope effects are different for the addition and subtraction routes and the relative rates are qualitatively in agreement with previous solid state experiments, although surface effects may also play a decisive role. Therefore, the effect of water molecules and a formaldehyde molecule on the abstraction and addition tunnelling reactions is also studied down to 50 K for selected isotopologues. The gas phase rate calculations indicate that for H/D + H2CO, abstraction is preferred over addition, but addition is more favourable than abstraction for the H + D2CO reaction. The presence of water molecules enhances the addition reaction and reduces the abstraction reaction, while an extra formaldehyde molecule does not affect the gas phase reaction rates strongly. H addition is preferred over abstraction in water-rich ices, but in apolar ices abstraction is preferred, which could enhance deuteration of formaldehyde and methanol. The calculated reaction rates are in qualitative agreement with recent experimental findings which suggest that H/D exchange in formaldehyde as well as methanol may be contributing to the observed deuterium enrichment in formaldehyde and methanol in the ISM.