a.
Thomas and Nils both make 1009 moves and Nils makes the last move. Nils can make sure that the last card on the table contains a number that is not divisible by 3. Indeed, he could start taking cards with numbers that are divisible by 3, until all these cards are gone. Because there are only 672 such cards, he has enough turns to achieve that.
We now consider the situation before the last move of Nils. Let k be the number on the last card, and let the sums of the numbers of Thomas and Nils at that very moment be a and b. Nils has two options. If he gives away the last card, the difference between the outcomes becomes (a+k)−b, and if he keeps the card, the difference becomes a−(b+k). Nils is able to win, unless both numbers are divisible by 3. But in that case (a+k−b)−(a−b−k)=2k would also be divisible by 3. Because k is not divisible by 3, the number 2k is also not divisible by 3 and hence Nils can win with certainty.
b.
Nils can win. We distinguish three types of cards, depending on the number on the card: type 1 (the number has remainder 1 when dividing by 3), type 2 (the number has remainder 2 when dividing by 3), and type 3 (the number is divisible by 3). Because 2019=3⋅673 and the card 2020 is of type 1, there are 674 cards of type 1, 673 cards of type 2, and 673 cards of type 3.
In order to win, Nils chooses a card of type 3 in his first turn (and gives it to Thomas). Then there are 674 cards of type 1 left, 673 of type 2, and 672 of type 3. In the next turns he responds to Thomas's move in the following way (as long as he is able to).
(i) If Thomas chooses a card of type 1, then Nils chooses a card of type 2 and gives it to the same person that got Thomas's card.
(ii) If Thomas chooses a card of type 2, then Nils chooses a card of type 1 and gives it to the same person that got Thomas's card.
(iii) If Thomas chooses a card of type 3, then Nils does the same (and gives the card to Thomas).
As long as Nils keeps this up, the sum of each player's cards is divisible by 3 after his turn (because a number of type 1 and a number of type 2 add up to a number which is divisible by 3).
Because the number of cards of type 3 is always even after Nils's turn, Nils can always execute his planned move in case (iii). Because the number of cards of type 1 is always 1 greater than that of type 2 after Nils's turn, he can also always execute his planned move in case (ii). Only at the moment when all cards of type 2 are gone and Thomas takes the last card of type 1 (case (i)), Nils cannot execute his planned move. However, in that case Nils cannot lose anymore. Indeed, after Thomas's turn the sum of the cards of one player is still divisible by 3, but the sum of the cards of the other player is not divisible by 3 anymore. Because there are only cards of type 3 left now, this will stay the same until all cards are gone. At the end, the difference between the sums of both players is not divisible by 3 and Nils wins.