What you're actually doing is finding the Least Common Multiple (LCM) of the denominators. That is, what is the smallest number that is divisible by both denominators.
Let's list out the multiples of 5 and 6 to illustrate this:
5, 10, 15, 20, 25, 30, 35, 40, ...
6, 12, 18, 24, 30, 36, 42, ...
Notice that the first number to appear in both of these lists is 30. This means that 30/5 is an integer, and so is 30/6.
Now let's look at 6 and 12
6, 12, 18, 24, 30, ...
12, 24, 36, ...
The first number is 12. See how the numbers sort of overlap? 6 goes into 12, so when you list the multiples of 6 and 12, you'll get a small LCM number (unlike with 5 and 6 which didn't happen for a little while).
If the Highest Common Factor (HCF) of two numbers is 1, then the LCM of the two numbers is their product.
Factors of 5 and 6:
5 = 1, 5
6 = 1, 2, 3, 6
The largest number in both of these lists is only 1, which means that 5 and 6 have no common factors, so you need to multiply the two numbers to make the denominator equal.
Factors of 6 and 12:
6 = 1,2,3,6
12 = 1,2,3,4,6,12
The largest in both of these lists is 6, so this means that the LCM of the two numbers is going to be less than 6*12 = 72. Since the HCF is 6, then the LCM is 6*12 / 6 = 12.
Another example:
9 and 15. The factors are
9 = 1,3,9
15 = 1,3,5,15
The HCF is 3, so the denominator you are aiming for is going to be 9*15/3 = 9*5 = 45.
Checking the multiples of 9 and 15:
9,18,27,36,45, ...
15,30,45, ...
45 is the first to appear, so it seems to work.