In first case the distance between mirror and object is 20 cm as distance inside the mirror is also be calculated.
in 2 case when object is moved 6 cm towards mirror , the distance will become 8 cm because we are taking the object closer to mirror.so
10 cm - 6 cm = 4 cm.
And distance inside the mirror will also 4 cm.So the total distance in 2 case will be 8 cm
4cm + 4cm = 8cm