Think of the line segment AB as a subset of the number line where:
A: x=0
B: x=9
Since Point M is a randomly selected number from AB, then its relative distance from 0, say X will be uniformly distributed from 0 to 9.
Now, we want P( longer segment between AM and MB has length no more than 6)
= P( 3<X<6) [for the longer segment not to exceed a length of 6, it should fall between 3 and 6]
= (6-3)/(9-0) [using the Uniform distribution]
=1/3 QED