The DP may play defense at any position.
The DP may play defense for a player other than the FLEX player, that player will continue to bat but not play defense, and is not considered to have left the game.
This allows both the DP and FLEX to play defense at the same time.
The FLEX player may be substituted for at any time by a legal substitute and the FLEX position remains in the lineup.
The substitute becomes the FLEX player.
Therefore she can do anything the original FLEX player could do.
The FLEX player can replace the DP on offense (batting and/or running). In which case, the DP will leave the game.
This reduces the number of players in the lineup by one. However the number of batters does not change.