I'll explain how it works on example of ATP Masters 1000 tournament. The player who wins the tournament gets 1000 points, runner up gets maybe 500 points while semifinalist get around 200 and so on. Player keeps that points until the same tournament next year.
Meaning it is very easy for a player who had bad last season to rapidly gain points and for a player with good last season to rapidly lose points.
There is a actually two tables for ATP players where one of them keeps scores as I just explained (more important one) and the other one just adds up the points for that season, so no defending of the points.
What follows is written as example I don't have time to check actual finishes and points for the players at the moment.
The change between Thiem and Medvedev happened because Thiem probably had a lot of points to defend from last year, let's say 500 hundred and Medvedev had none or very little. He earned maybe around 1000 points for runner up space and effectively made up a difference of 1500 points vs Thiem in two weeks.
Hope it is a bit clearer now.