Navy ROTC scholarship midshipmen contract day 1 of Sophomore year. Note that you are signing that contract without any guarantee at all of in what role you will be serving. That is not decided (by the Navy) until senior year. Want aviation and was assigned SWO? Nothing you can do. This is why I keep telling people that if you want ROTC your main goal must be to serve as an officer. Job does not matter because it is not within your control. You can influence selection by your performance, test scores, etc but in the end it is totally up to the needs of the service. Period.
That sounds like how it worked in the Air Force circa 1980. You take a set of aptitude tests, and you get offered particular jobs based on your scores. If you don’t take any of those jobs, the Air Force assigns you a job based on Air Force needs at the time.
Officer assignments are more complicated than test scores but class rank is a factor. Class rank at USNA is more than just GPA though. Mids are also evaluated on leadership and fitness. But as @“Iron Maiden” pointed out, it’s needs of the service so desire to be an officer must be first. One year there may be a shortage of SWOs and another of aviators.