The rules do not have the words "The DP and the FLEX cannot switch positions"; that would be too easy.
But what you will find is that if the DP plays defense for the FLEX then
the FLEX will leave the game. (NFHS 3-3-6-e, ASA 4-3-E)
And if the FLEX plays offense for the DP (only spot she can play offense) then
the DP will leave the game. (NFHS 3-3-6-d, ASA 4-3-D
In both of these instances the team drops from 10 players to 9 players. They do not "swap".
The only way the DP and the FLEX can both be in the game at the same time is with the FLEX on defense and the DP on offense.