When deriving the Euler-Lagrange equation my notes bring the $\delta$ into the action integral, which is fine, which gives
$$\delta S=\int_{t_0}^{t_1}dt \frac{\partial \mathcal L}{\partial q_i}\delta q_i+\frac{\partial \mathcal L}{\partial \dot q_i}\delta \dot q_i \tag{1}.$$
We then use the fact that the time derivative of $q_i$ and the path modification $\delta$ commute to find:
$$\delta \left(\frac{dq_i}{dt}\right)=\frac{d}{dt}(\delta q_i) \tag{2}.$$
From here the derivation is fairly standard, my problem is why these two operations commute. $dq_i/dt$ is the "velocity" of that coordinate at a point along the trajectory, but surely if we modify the trajectory the velocity at that same point is no longer guaranteed to be the same? So why are we allowed to modify the path and then take the time derivative and guarantee we get the same value?