At the time of throwing the ball, it inherits velocity of platform at that moment . And, the horizontal velocity of the ball is constant in the air, because no acceleration in horizontal direction for ball. If train is accelerating in forward direction then from frame of train, the ball has horizontal component of acceleration in backward direction and vice versa.