An ideal string is massless and frictionless. The tension at every point is same. If some tension is developed in the string, then a common tension , say $T$ is present at every part of string. That means at a particular point two tensions $T$ will act in opposite directions. But If the the string moves with an acceleration a then how is it possible as by Newton's second law no net acceleration of a system is possible without an external force.
I think what is confusing you here is the nature of a massless string, which is a bit unrealistic (but very useful for demonstrating concepts).
Consider Newton's second law, it is the mass that resists the acceleration. A massless string has no resistance to acceleration. The required force to accelerate it from Newton's second law is: $$F = m a$$
If $m = 0$, then $F = 0$, it takes no force to accelerate the massless string.
A massless string may not really exist; but if it did, in the pulley situation it doesn't need an unbalanced force to accelerate, because massless objects can accelerate without force according to Newton's laws.
Objects without mass can accelerate without an external force.
$$F = ma$$
If $m = 0$ , $F$ is always equal to zero but $a$ may or may not be zero.
There is no restriction on the acceleration of a string, only that the net force acting at any point in the string is zero as $m = 0$. This is why at every point on the string tension acts in opposite directions, except perhaps at the endpoints where there is tension acting only in one direction balancing any external force that may be present.
The net force is acting on whatever masses are connected to the string, not the string itself which is massless. Think of the string and attached masses as a system. The masses and the string accelerate as a unit due to a net external force on the system. The tension in the string is an internal force.
To further illustrate, see the free body diagrams (FBD) below on an example of two masses connected by a string.
The top diagrams show FBDs in the case of a "massless" string. Of course there is no such thing as a massless string, but we can alternatively say the mass of the string is so much less than the two masses connected to it that it can be considered negligible. The last equation gives the tension in the string. It can be cut anywhere and the tension will be the same and depend only the connected masses. Note also that as $M_2$ approaches zero, the tension approaches zero as well, as we would expect.
The bottom diagrams show FBDs for the case where the string does have mass, $M_s$. In this example the string is cut exactly in the middle, so half of its mass is on either side. The final equation for the tension now shows it will depend on the mass of the string as well as the connected masses. In this case the tension will not be the same throughout the string and instead will depend on where it is cut. The further to the left it is cut, the less the tension.
Hope this helps.
This cancelling of tensions at a point is only possible in equilibrium. Your reasoning shows this. If every point is in equilibrium then each point can't accelerate and there is no way for the rest of the string to know that one end is accelerating. The problem is that we think of strings as percectly inelastic and while that is often almost the case, there are cases like this where this breaks down.
To make sense of this divide your string into multiple points with a small mass and connect them with ideal rubber bands. When ideal rubber bands are below rest length they provide no tension (they buckle) but when they are extended beyond their rest length they provide a force $-k(d-d_0)$. Here $d$ is the current length and $d_0$ is the rest length. Now if you let $k$ become really large and add a lot of friction your string will behave more and more like an ideal string.
If you now accelerate one end of this almost-ideal string you will indeed have that each point is slightly out of equilibrium.
I think that the correct system is: massless spring + mass m at one end + force F at the other end.
If the system is hanging from a hook, F is a reaction force, balancing the weight mg.
If the system is free from a gravitational field, the effect of the force is an acceleration: a = F / m and there is a tension F in the spring.
The deflection of the spring, measuring the tension is a kind of intrinsic indicator for an accelerated frame of reference, or gravitational field.