DD was middle to bottom of the pack in compulsory levels but has done much better as an optional gymnast, both in how she places, and her actual scores. In L7, she got better scores (consistently) for vault, floor, and bars, and AA. Scores similar only for beam. There was more than one gym switch (one due to family relocation, the other for gym-specific reasons) so her three seasons of compulsory meets (one year each in old L4, new L4 and new L5) were not at her current gym. Coaching obviously is part of it, but both former gyms have very strong compulsory and optional teams.
I think part of it is mental...maybe some gymnasts (DD included) focus much better at age 12 than at age 9, whereas some seem more distracted by life at age 12!
As for the physical part: DD has always lacked power/strength compared to other gymnasts who train similar hours. And she's not particularly flexible or graceful

. But, over the years, coaches of other sports in which she participated (soccer- probably 3 different coaches said the same thing- as well as tennis and diving) have commented that DD has really good 'spatial awareness'. I wasn't sure exactly what that was at first, but here's a definition I found: 'Spatial awareness is how well you’re able to sense the location and position of your body in relation to your physical surroundings. Being spatially aware means you have a sense of spacing, timing and direction and it directly impacts your performance during sports and other athletic movements'. I heard this 'strong spatial awareness' comment for the first time when she was 4 years old, well before she ever started gymnastics.
So...one theory I have as to why DD is better at optionals is this: maybe the 'spatial awareness' strength is important like for all that harder bar stuff

/ flipping the vault/ adding twists to existing tumbling, etc. but maybe doing compulsory skills extremely well just doesn't require the same degree of spatial awareness? Again, just a theory

. But to your question, yes, some gymnasts do better in optionals.
Interestingly, many of DD's former teammates who were always the top compulsory performers are either no longer in the sport, or have not yet competed L7...