There is an article on Wikipedia gravity assist and in the explanation of the term, author gives an analogy:

Isn't this violating the law of conservation of energy and momentum? Can someone make a mathematical proof of this? I tried, but the variables like the mass of the train and the tennis ball are missing - I'm interested how is it possible to predict such a movement without doing a calculation.

No, because the train is slowed down a little by the collision, and transfers some of its kinetic energy and momentum. The same happens with a moving planet that you use for gravity assist. Or with the moving air mass that you use in dynamic soaring:

I understand that it transfers it's energy and momentum, but how can we say that the velocity of the ball will be 130 m/s without knowing the momentum of the train nor the tennis ball? We can't know how much energy and momentum will be transfered.

That's just an idealization, which assumes the collision is perfectly elastic and the mass of the ball is negligible compared to the train's mass. In reality it will always be less than that.

Let velocity of train be v and that of ball initially be u .

Use formula for e → e = v_{sep}/v_{app} . e ≈ 1 ( not exactly , as AT has said ) . This gives you → v_{1} - v = u + v ( where v_{1} is final velocity of ball - in opposite direction ) .

I am using the definition of the coefficient of restitution ( e ) - velocity of seperation upon velocity of approach - between two bodies , which is valid for all collisions .

This is usually in the range of 0 to 1 → 0 for a perfectly inelastic collision and 1 for an elastic collision ( Why ? - See relative velocity ) .

Since this is assumed an almost elastic collision , I take e = 1 , and write v_{approach} = v_{seperation} .

This is easiest to see in the center of momentum frame. In that frame we have:
##m v_0 + M V_0 = 0## before the collision and
##m v_1 + M V_1 = 0## after the collision due to conservation of momentum and
##v_0 = -v_1## and ##V_0=-V_1## due to conservation of energy.

Solving for ##\Delta v = v_1-v_0## and ##\Delta V = V_1-V_0## and eliminating ##v_1##, ##V_1##, and ##V_0## we get:
##\Delta v = -2 v_0##
##\Delta V = 2 v_0 m/M##

In the limit as ##m/M## goes to 0 we have ##\Delta V## goes to 0, so the center of momentum frame is approximately the frame of the more massive object if the masses are very different. So the small object bounces back with twice the speed and the large object is (approximately) unaffected.

When you bounce a ball off a wall, the velocity change is 30 - (-30) = 60 m/s. Double the initial speed because you changed from 30m/s in one direction to 30 m/s in the other.

He isn't asking about the velocity change (which would be 160m/s not 60m/s is his example). He is asking about the speed change, which is double the wall(train) speed (not double the initial ball speed).

Since this is a 1d problem, speed change and velocity change are the same and whether its the ball or train speed he's concerned about, the choice of which object/frame is called "stationary", doesn't really change anything except the perspective. Ie, if the ball is moving toward a stationary wall at 30 m/s or the wall is moving toward the ball at 30 m/s, the speed change of the ball is the same 60 m/s. Adding a 3rd frame and adjusting the values doesn't change how that works. And from that one explanation, the OP should be able to figure out any other permutation.

There is also an implied assumption in these problems that the wall/train is truly unchanged by the collission. As such, only the ball's momentum is relevant, it is conserved and since the mass is constant, you can just use speed.

No they aren't. In the given example the speed changes from 30 to 130 km/h (a change of 100 km/h), while the velocity changes from -30 to 130 km/h (a change of 160 km/h).