Teams generally use two basic organizations, one when they have the ball and another when they don't have it. A 4231 in attack can and often will be a 442/4411 in defense.
4-2-3-1 is actually much more complex than that.
The reason this particular formation have thrived is not because it has two deep midfielders like a lot of people would point out. It’s because this formation is flexible both in defense and attack.
Essentially in attack it can become: 4-3-3, 4-3-2-1, 4-4-2, 4-4-2 diamond, 4-4-1-1, 4-2-2-2 and 4-2-4 with almost seamless transition. Depending on the instructions of the coach and flow of the game. Sometimes it’s so subtle that fans don’t even notice it. Including the original starting positions, that’s 8 variations. That’s providing the full back doesn’t play as a winger as has been the case in certain teams, which could even lead to back 3 formations and even further variation.
Similarly in defense it can become: 5-4-1, 4-1-4-1, 4-4-2, 4-4-1-1, 4-3-2-1, 4-5-1, 5-3-2 and even 4-6-0.
The formation itself is not important. Where players are placed at kick off and goal kicks is not often where they play. Heat maps show just how wide of an area players make up. If they were rigid like people often believe, it would mostly be a square box. Players are no longer confined to zones in the traditional sense.