As you have read that if in a fraction the denominator is of the form
that fraction is terminating where m and n are positive integers.
Otherwise if in a fraction the denominator is not of the form
than the fraction is non terminating repeating.
So rational number can be terminating as well as non terminating repeating.
So, you can see as in 2,4 ,8,16,32 the denominator is of the form
. That's why the decimal terminates.
Now look at fractions having denominators 6,12,18,24. Now among all these numbers

The prime factor of all these numbers contain factor other than 2 i.e 3 also.
As i have written above if the denominator is not of the form
then the decimal is non terminating.