one counter-example is all it takes to disprove something. sometimes HUK is a subgroup, for example, this will always be true if one subgroup is contained in the other.
with sets, HUK is the set generated by H and K. it is the smallest subset of some set that contains both H and K (the "universe set") that contains both H and K.
by contrast, the smallest group containing both H and K is <HUK>, and it is easy to see that while for a given set S, <S> contains S, it need not equal S.
Z is a perfectly good place to observe this phenomenon.
we know that every subgroup of Z is cyclic, and therefore it has a generator. pick two positive numbers ≠1 in Z that are relatively prime, say k and m.
let's see if <k> U <m> is a subgroup. since k,m are relatively prime, we can find integers s,t such that sk + tm = 1.
now sk is in <k>, therefore in <k> U <m>, and tm is in <m> therefore in <k> U <m>, so if <k> U <m> is a subgroup,
sk + tm = 1 is in <k> U <m>, so all of Z is in <k> U <m>, since 1 generates Z.
now consider km + 1, which, being in Z, is certainly in <k> U <m>, so is either in <k>, or in <m>.
let's suppose it is in <k>, so we have km + 1 = ku, for some u, so k(u-m) = 1
the only value for k for which this works is 1, contradicting our choice of k.
so km +1 must be in <m>, so km + 1 = mv, for some v, so m(v-k) = 1, and then m = 1.
but we chose both k,m ≠ 1, so <k> U <m> must not be a subgroup of Z.
(you can check that if k = 2, and m = 3, that 2+3 = 5 isn't a multiple of 2 or a multiple of 3).