The observational detection of some metastable isomers in the interstellar medium with abundances comparable to those of the most stable isomer, or even when the stable isomer is not detected, highlights the importance of non-equilibrium chemistry. This challenges our understanding of the interstellar chemistry and shows the need to study isomeric forms of molecular species to constrain chemical processes occurring in the interstellar medium. Our goal is to study the chemistry of isomers through the sulphur isomer pair HNCS and HSCN, since HSCN has been observed in regions where its stable isomer has not been detected, and the observed HNCS/HSCN ratio seems to significantly vary from cold to warm regions. We used the Nautilus time-dependent gas-grain chemical code to model the formation and destruction paths of HNCS and HSCN in different astrochemical scenarios, as well as the time evolution of the HNCS/HSCN ratio. We also analysed the influence of the environmental conditions on their chemical abundances. We present an observational detection of the metastable isomer HSCN in the Class I object B1-a ($N$=(1.1pm 0.6)times 1012 cm$^ $), but not of the stable isomer HNCS, despite HNCS lying 3200 K lower in energy than HSCN. Our theoretical results show an HNCS/HSCN ratio sensitive to the gas temperature and the evolutionary time, with the highest values obtained at early stages ($t$lesssim 10$^4$ yr) and low ($T_ g $lesssim 20 K) temperatures. A more detailed analysis also shows that the main mechanism forming HNCS in young ($t$$<$10$^5$ yr) and cold ($T_ g $$=$10 K) objects at moderate-low densities ($n$$_ H $leq 10$^5$ cm$^ $) is a grain surface reaction (the chemical desorption reaction N$_ solid $+HCS$_ solid $rightarrow HNCS), unlike previous predictions that suggest only gas-phase chemistry for its formation. However, for the formation of its metastable isomer HSCN, over the same time range and physical conditions, we find that both surface and gas-phase reactions (through the ion H$_2$NCS$^+$) play important roles. In warmer ($T_ g $geq 50 K) regions, the formation of this isomer pair is only dominated by gas-phase chemistry through the ions H$_2$NCS$^+$ (mainly at low densities) and HNCSH$^+$ (mainly at high densities). The results suggest a different efficiency of the isomerisation processes depending on the source temperature. The progressive decrease of HNCS/HSCN with gas temperature at early evolutionary times derived from our theoretical results indicates that this ratio may be used as a tracer of cold young objects. This work also demonstrates the key role of grain surface chemistry in the formation of the isomer pair HNCS and HSCN in cold regions, as well as the importance of the ions H$_2$NCS$^+$ and HNCSH$^+$ in warm/hot regions. Since most of the interstellar regions where HSCN is detected are cold regions (starless cores, Class 0/I objects), a larger sample including sources characterised by high temperatures (e.g. hot cores) are needed to corroborate the theoretical results.