It was evident that we didn't see much of Captain Marvel in Avengers: Endgame as we anticipated, she had a limited role as it is shown in the movie that she needed to help other planets that were affected by the snap.
Captain Marvel showed briefly at the start of the movie where she helped with beheading Thanos but had to leave as soon as possible to assist others as much as she can, then later showing up at the final battle.
In a recent interview with Vanity Fair, Avengers: Endgame writers Stephen McFeely and Christopher Markus explained why Captain Marvel didn’t have a lot of screen time despite its character.
"Well, she was always going to be in it but we didn't have much to go on. They had cast her and that was it. It is a tough balance to strike when you have a character that powerful who you're going to bring in, and you don't want it to seem like, well we just brought in this person who can clean the house that we couldn't clean in the previous movie. So, we had to decide on a balance between not making it feel like a cameo but not having her around so much that she solved all of the problems for everybody” Markus stated
He felt like they had to at least find a good place where Captain Marvel’s role just fits right.
In relation to that, McFeely added "It also wasn't the point of the movie, the point of the second movie was saying goodbye to the original six Avengers, so their stories were gonna be way up here. It was not fair to the other six Avengers to have Captain Marvel come in and solve all their problems, it didn't seem like good storytelling"
Both of the writers had to come up with a story that doesn’t put Captain Marvel in a spot where she overshadows the other characters that were an integral part of the story, given that fact that she is a powerful hero, she could easily stand out and since this is the last movie where the 6 original characters are shown all together, the writers made it a point to revolve the story around them.
Although Captain Marvel didn’t have a lot of screen time in Avengers: Endgame, this also points to the fact that her role would be the foreground of her own movie, Captain Marvel 2, which was announced as part of Phase Four of the MCU.