Consider a system consisting of two particles of a given mass, floating in space, aligned horizontally, constrained to remain at a fixed distance from each other by a massless thin rod (or string). If I apply a horizontal force on the first particle (meaning it is parallel to the vector joining the two particles), the second particle is forced to accelerate due to the constraint force between the two. In other words: If I draw a Free Body Diagram of the second particle, the only force acting on it is the constraint force, or the force caused by the pull of the rod or string, and since this second particle does accelerate in the same direction, then said force is doing work on it. How is this not a counterexample to the assumption in analytical mechanics that constraint forces do zero work? Or how I am misinterpreting such principle?
You forgot to account for the constraint force on the first particle too, it would be of the same value but opposing the motion instead. If you take both particles together as your system then this force is adding kinetic energy to the 2nd particle whilst taking the same amount of kinetic energy from the first, so the change in energy (and thus the work) in the whole system is zero.
Your example is very interesting. The force you apply is where all the work is done.
The connection between the first object and the constraint experiences an opposite force to that between the constraint and the second object. But the constraint means they move the same distance. The work done at one end is undone at the other.
In effect, the constraint takes some of the work you do 'on' the first object and transfers it to the second. It does no work itself.
In ordinary usage, a constraint force shows up as, for example, the force experienced by a moving ball that encounters a curved ramp which changes the direction of its travel. That force is responsible for furnishing the acceleration that tips the ball's velocity vector, but since it does not act on the ball in the direction of the ball's velocity, it performs no work on the ball, and the kinetic energy of the ball is unchanged by traversing the curve.
In the example you give, the two-masses-connected-by-a-rod system can be simplified by lumping the masses into one, in which case the force you are applying to it gets transmitted internally by compressive stresses between the individual mass elements within the one lump instead of by compressive stresses that form within the rod connecting the two lumps.
The forces associated with those internal stresses do not constitute "constraint forces" as defined in the first example above.