In part the confusion is because assumptions are made at the start of an analysis and then changed during the analysis.
The simplest system to analyse is an ideal one where the masses are point masses, the string is massless and inextensible, the pulley is massless, there is no friction and the final (steady) state of the system is being considered.
With these assumptions:
For the string the magnitude of the force it exerts on mass $m_1$ at one end, $T_1$, is always exactly equal to the magnitude of the force it exerts on mass $m_2$, $T_2$, at the other end, so $T_1 = T_2 = T$.
Because the string is inextensible the magnitude of the acceleration of one end of the string and hence mass $m_1$ is equal to the magnitude of the acceleration of the string at its other end and hence mass $m_2$, so $a_1=a_2 = a$.
An ideal massless and inextensible string transmits forces between masses and changes the direction of the forces.
Assume that $m_2 > m_1$.
The equations of motion for the two masses can be obtained using Newton's second law:
$m_2 a = m_2g - T$ and $m_1a = T-m_1g$.
With the assumptions that have been made there can be no discussion of how the system reached a state where the acceleration was $a$ from a different set of initial conditions.
If the string had some mass, $m_s$, but was still inextensible then the equations of motion are:
$m_1 a = mg - T_1, m_2a = T_2-m_2g$ and $m_sa = T_1-T_2$.
Note here that as $m_s \rightarrow 0 $ then $T_1 \rightarrow T_2$.
Now consider a real system with the string having a mass, $m_s$ and also capable of being stretched with a "spring" constant $k$.
To make the analysis easier, initially the string has its centre of mass directly over the axle of the pulley, masses $m_1$ and $m_2$ are at rest being held up by upward forces $m_1g$ and $m_2g$ and the string is taut.
The ends of the string exert no forces on the masses.
Remove the upward forces $m_1g$ and $m_2g$ simultaneously and apply Newton's second law.
$m_2 a_2 = m_2 g \Rightarrow a_2 =g, \quad m_1 a_1 = m_1 g \Rightarrow a_1 =g, \quad m_s a_s =0 \Rightarrow a_s = 0$.
The reason for these surprising? accelerations is that it takes time for the information/pulse/wave to travel along the string.
Thus one end of the string does not know what is happening to the other end.
That speed depends on, amongst other things, the "spring" constant of the string and the mass per unit length of the string.
As the "spring" constant gets bigger and the mass per unit length gets smaller so the speed of information transfer gets larger.
Linking this with the ideal massless and inextensible string the implication is that for such an ideal string the information travels at an infinite speed.
This would mean that any changes to acceleration etc happen instantaneously.
For a normal string the speed of information transfer is relatively high, so much so that it is unlikely that those initial accelerations would be observed?
So now you have two masses accelerating downwards at $g$ and the centre of mass of the string at rest.
I do not know exactly what happens before the system settles down to some sort of ideal system behaviour but there must be a time when mass $m_1$ actually stops again and then starts moving upwards.
There may well be some oscillations in the string and perhaps even the masses actually oscillate as well as accelerating in a "clockwise" direction.
With friction and other dissipative forces present those initial "oscillations" will be damped down in a short period of time and again I think that it might be difficult to observe them.
A suggestion is that an apparatus is set up, with unequal masses connected by a spring which goes over a pulley, to see if any of the effects that I have described are visible.