The 2-2-2 composition that you see in public matches arise more or less due to redundancy. You want to make sure that someone on the team can still heal, or still peel/CC when someone dies.
“Dive” was a 2-2-2 composition but that had more to do with specific character synergies than anything else. D.Va and Winston are the most mobile tanks (before Wrecking Ball was a thing) and were able to just pounce on any single enemy hero who was slightly out of place, while Genji and Tracer are also mobile and can chase down anyone trying to flee. Zenyatta can heal allies without line of sight, and discord orb was also useful for quickly removing the isolated target that Winston and D.Va picked out. Mercy was always picked just for consistency of healing and mass rez when it was a thing, and was also mobile enough to be able to follow the Dive.
The initial design of Overwatch back when it first came out expected teams to have just 1 healer and 1 tank, although eventually the in-game tooltips nudged people towards 2-2-2. The “offense” and “defense” categories for the DPS heroes also never made much sense. McCree was “offense” even though his lack of mobility and ability to stun people made him a more defensive hero, and the snipers were categorised as “defense” even though in competitive play, they were almost exclusively used as wall-breakers due to their high single-target damage. Double sniper was often seen in OW League on the attackers side on some maps, particularly King’s Row. However, most players aren’t really aware of the higher level of play in any sense, and I often saw players who picked a sniper on attack being accused of “throwing” even though the competitive meta has shown that one or more snipers on attack can be extremely useful. The offense/defense classification was eventually removed and merged into one big DPS hero class, and it’s kinda funny that the current competitive meta more or less ignores the largest category of heroes.