Animating between mask paths in After Effects
Like @stib said above, masks interpolate in a straight line. However, you can also use tools like the Smart Mask Interpolation panel to tell After Effects to re-examine how the masks are interpolated between each other and find a better route, but this creates a TON of keyframes (one per frame actually) so if you plan to make additional changes to the masks later, this isn't the best option.
If it were me, I would just do each line as its own animation, and use a 10-15 frame hand animated loop, so you have control over each individual line itself...once the first crease in the flag moves from one end to the other, you can just loop that part over and over...
More info on Smart Mask Interpolation here:
https://www.provideocoalition.com/managing_moving_masks/