Possible lengths for the 6cm pieces include: 6, 12, 18, 24, 30, ...
These are all multiples of 6.
Likewise, the possible lengths for the 8cm pieces include: 8, 16, 24, 32, ...
These are all multiples of 8.
Notice that the smallest number that appears in both lists is 24. This is your answer.
Mathematically, 24 is called the least common multiple.
Hope this helps.