The #lcm# is the product of all the factors raised to the highest power they have in the given terms.
We can rewrite #18m^2# as #2*3^2*m^2#, and we can rewrite #24nm# as #2^3*3*n*m#.
The highest power of #2# appears in the 2nd term: #2^3#.
The highest power of #3# appears in the 1st term: #3^2#.
The highest power of #m# appears in the 1st term: #m^2#.
The highest power of #n# appears in the 2nd term: #n#.
The #lcm(18m^2,24nm)# is just the product of all of these pieces:
#lcm(18m^2,24nm) = 2^3*3^2*m^2*n=72m^2n#.
Bonus:
What happens if we simply multiply these two values together?
#18m^2*24nm=(2*3^2*m^2)*(2^3*3*n*m)#
We know this will be a multiple of both terms, but it's not going to be the lowest common one, because they both have some (prime) factors in common. We can reduce this product by dividing out those common pieces. Let's take this product and cross out the divisors the two terms have in common:
#(cancel(2)*3^2*m^2)*(2^3*3*n*m)#
They both have at least one #2#, so we cross a 2 out.
#(color(grey)(cancel(2))*3^2*m^2)*(2^3*cancel(3)*n*m)#
Same goes for the #3#.
#(color(grey)cancel(2)*3^2*m^2)*(2^3*color(grey)cancel(3)*n*cancel(m))#
Only one has an #n#, but they both have at least one #m#. Cross this out.
We're left with #2^3*3^2*m^2*n#, which is the #lcm#. What we ended up crossing out is #2*3*m#, the product of the divisors the two terms had in common. In fact, this product is called the greatest common divisor (#gcd#). This leads us to an interesting formula:
#lcm(a,b)=(atimesb)/gcd(a,b)#,
or
#gcd(a,b)timeslcm(a,b)=atimesb#.
Basically, this says "the pieces that are crossed out #times# the pieces that are not crossed out #=# all the pieces". This formula is useful because the #gcd# is often easier to see.