First of all, no matter what all those kindergarden "everyone wins if you're having fun" roleplayers say, D&D very much has competitive elements at its core. The DM plays enemies and is expected to challenge the players, which does require a seperation of roles - build the adventure to be fair and enjoyable, but try your best to have the monsters succeed at their goals (which might but not necessarily involves eliminating the party). Also, the puzzle to solve is those challenges the DM presents you, not the game itself - and working as a team is a central part of the equation.

D&D optimization is a skill that can be applied to most roleplaying games with character advancement, with evaluating what best helps your concept.