I can reproduce the problem and have created an improvement task for it, as technically, it is not a bug, as no logic resets the settings as soon as you change the display value. However, I can understand that it can be very confusing when switching between flex and grid (this also applies to other settings that can be used in both areas, such as the flex align settings).
At first glance, this logic seems relatively simple, but it is not, as some settings overlap and some do not.
In the case of the gap, one possible solution would be to merge the row- and grid-gap of the flex settings into a “gap” field, as we do with the grid. However, I cannot promise you whether this is feasible.