The USNA class of 1945 graduated as the class of 1944, because of "War-Accelerated Graduation" requirements.
915 of them graduated in only 3 years, on June 7, 1944 (the day after D-Day).
Less than a year later, one of that class (Richard McCool) was awarded the Medal of Honor.
I'm a history dork, okay?
Back on track, though - I think a longer service commitment is a good thing in theory, but honestly (just as
@MiddyB wrote) the "supply" of officers in the chain is pretty well thought out.
This is especially true for The Corps. They need those o-1 through o-3 billets filled, but if you don't make o-4 after that first look at you for it, the writing is on the wall. The Corps won't flat out say
"we don't need you anymore", but they will make it so plain that you would be a blockhead to miss it.
Unless there's a Reduction in Force. That's pretty much when they tell you "Here's your cover, pal - don't let the door hit you on the way out"