First case:
2Mg - T = 2Ma ---------------(1)
T - Mg = Ma ----------------(2)
Solving we get a = g / 3 and T = 4 Mg / 3 ---------------(3)
Second Case:
In this case we are pulling the other end with a force 2Mg, which is nothing but the tension in the string.
Therefore
T = 2Mg ---------------(4)
T - Mg = Ma --------------(5)
Solving we get a = g and T = 2 Mg ----------------(6)
Third Case:
In this case we are pulling the mass M with a force Mg. Therefore the equations of motion are,
Mg + Mg - T = Ma ----------------(7)
T - Mg = Ma ------------------(8)
Solving we get a= g / 2 and T = 3Mg / 2 --------------------(9)
The motion of the insect is possible only when there is friction. This frictional force is considered as external force for the insect.