This is the problem of accelerating reference frames. Newton's first law:
In an inertial frame of reference, an object either remains at rest or continues to move at a constant velocity, unless acted upon by a force
can be seen as a condition for the other laws to hold true. The frame that is moving with the train is obviously an accelerating reference frame, so it is not inertial and we can expect forces where there shouldn't be. These forces that appear in accelerating reference frames are called fictitious forces or pseudo forces. Imagine you are on a very fast merry go round and you place a bucket of water in the center. The water will bulge to the sides of the bucket with no apparent cause (from your frame of reference). This is also an effect of non-inertial frames.
When you do find a frame that is inertial everything works like you expect. Newton's laws hold and there are no fictitious forces. From the frame that is outside the train everything looks fine. The train is accelerating and the bob is pulled along with it, only with delay because the force has to act via the rope. The rope can only exert sideways force if the bob is not hanging directly under it.