There were 21 flags and each player had the opportunity to remove 1,2, or 3 flags. The player that removes the last flags will be the winning team. By applying the backwards induction theory, think backwards in time and the optimal winning strategy is to leave the opponent player 4 flags by each step to remove the flags so that the remaining number is divisible by 4.
The player that has the first attempt to remove the 1st flag will control the 100% of whole situation. This is the unbeatable strategy that will lead the whole situation by leaving the opponent player with a multiple of 4 flags. This apply when both player understand the trick of this 21 flags game. By leaving the opponent player with 20 flags at the first attempt, no matter how many flags the opponent player remove, the player that in control could then remove the flags and leave the opponent with 16 flags, then 12 flags, then 8 flags and finally 4 flags which forces the opponent in to a situation where no matter how many flags the opponent player remove, the in charge player will be able to take the last flag. The key of this game is the target number you arrange it so you leave your opponent player with. Then whatever amount of flags the opponent player take, you can remove the remaining 1 to 3 flags that sum up to 4. The first attempt to remove the 1st flag of this 21 flags game has the upper hand.
However, if you lost the first attempt to remove this game, you better hope the opponent player do not know the trick of 21 flags. By this, you may still stand a chance to get back the control of this game by playing randomly to confuse the opponent player and try to get back the target number of 4. Unless the opponent understand well the strategy of this game else they most probably will go to make a mistake and allow you to control back the situation by getting back the situation where flags number able to be divide by 4 before ending the