I would imagine Starfleet's Unrestricted Line (Command) officers would have to attend the Academy in order to be commissioned. That would directly correlate to the real-life Navy.
On the other hand, in the Navy, enlisted can also commission as a "limited duty" officer. These officers are not eligible for command of a ship, and do NOT attend any service academy (or commission through ROTC)--they go to a special course for limited-duty officers. (Note, that the Navy does call it an "Academy", but it's just a four-week orientation program, tailored to the needs of newly commissioned limited duty and Chief Warrant officers.)
Note also that LDOs can convert to Unrestricted Line if they earn a Bachelor's degree and are selected to attend regular OCS. This is rare but does happen.
An aside:
Marines are a different story. All officers are "line" officers, whether regular, limited duty, OR Chief Warrant. This means that all Marine officers have to be qualified to command a combat unit (read: platoon), should the need arise. This is because the Marines have no "Staff Corps" of their own. The Navy supplies all of those.