Hint $\ $ As here cancelling $\,d := \gcd(a,b)$ from both sides we reduce to the case $\,\bar a,\bar b\,$ coprime
$$\bar a \bar b = 12,\,\ \gcd(\bar a,\bar b) = 1,\,\ {\rm for}\ \ \bar a,\,\bar b := a/d,\,b/d\qquad $$
Examining coprime factorizations $\,\bar a\bar b = 12 = \color{#90f}{1\cdot 12} = \color{#0a0}{3\cdot 4}\,$ satisfying our constraint
$$ \color{#c00}5 = a\bmod b = \bar ad\bmod \bar bd = (\color{#c00}{\bar a \bmod \bar b})\,d\qquad $$
we see $2$ of the $4$ possibilities satisfy $\,\color{#c00}{\bar a \bmod \bar b}\,$ divides $\color{#c00}5,\,$ e.g. $\,\color{#0a0}{4\bmod 3}\,$ does but not $\,\color{#0a0}{3\bmod 4}$. Check the same for $\color{#90f}{1\cdot 12}$ and we're done. Total solution time: a minute of easy mental arithmetic.
Remark $ $ The key idea used above is that we can reduce to that case of $\,a,b\,$ coprime by cancelling $\gcd(a,b),\,$ since the equation is homogeneous in $\,a,b,\,$ due to the distributive law for lcm and gcd, i.e. $\,{\rm lcm}(a,b) = d\,{\rm lcm}(a/b,b/d) = {\rm lcm}(\bar a,\bar b),\,$ $\,\gcd(a,b) = d\gcd(a/d,b/d) = d\gcd(\bar a,\bar b).\ $ This reduction makes the problem so simple that we can quickly finish purely mentally, i,e. check the $4$ possible coprime $\rm\color{#90f}{split}\color{#0a0}{tings}$ of $12$ to see which satisfy the mod $\rm\color{#c00}{constraint}$.
Such homogeneous reduction often leads to analogous simplifications, e.g. see here and here and here for further examples. In more advanced contexts one doesn't explicitly change variables $\,a,b\to \bar a,\bar b\,$ then cancel $\,d;\,$ rather one simply writes: "being homogeneous in $\,a,b\,$ wlog we may reduce to the case $\,a,b\,$ coprime $\ldots$".