I am about to nerd out here at a level that I can only hope causes Snarf to say, "Damn, son. You really need to tone it down."
As far as I can tell, the idea of Starfleet being anything other than a military organization originated after the original series stopped production. In the original series, Kirk refers to himself as a soldier, there's an episode literally called "Court Martial," there's the rank system and organization you point out, and most importantly it's Starfleet who prosecutes wars on behalf of the Federation. Nobody watching "Errand of Mercy," "Arena," or "Balance of Terror" in the 1960s ever thought Starfleet was anything other than a military organization.
Despite the disappointing box office return of Star Trek the Motion Picture, Paramount gave the greenlight to a sequel but they did not want Gene Roddenberry in charge. They didn't use Roddenberry's script which involved the crew of the Enterprise going back in time to the 1960s to foil a plot by time traveling Klingons. So they made Roddenberry a consultant so they could put him out of the way without pissing off Trekkies. Roddenberry hated the script for Wrath of Kahn beliving it to be too militaristic in tone. There is some speculation that Roddenberry was the one who leaked details of Spock's death to the public out of spite.
It wasn't until The Next Generation that the idea that Starfleet wasn't a military organization was floated. In 1991's 2nd season episode "Peak Performance," the Enterprise is assigned to a training exercise as part of Starfleet's effort to figure out how to handle the new Borg threat. From the very beginning, Picard and Riker consider it a waste of time as the captain says, "Starfleet is not a military organization, its purpose is exploration." Keep in mind that just a few episodes earlier the Enterprise got their rear end handed to them by the Borg losing several crewmembers in the process only surviving because Q interfered.
And ever since then there's been an insistance that Starfleet wasn't really a military. Nevermind the whole Dominon War arc on Deep Space 9. I remember Nichelle Nichols insited Starfleet wasn't a military organization, they were more on par with the U.S. Coast Guard. I guess she didn't know the USCG was one of the braches of the United States Armed Services same as the Army, Navy, Air Force, and Marines. The remake of Wrath of Khan has a scene where Scotty rhetorically asks Kirk if "they were a military now?" Yes! Yes you are! You've got an admiral that's about to start a war. You're a military.
I don't care if Starfleet's main job is exploration, science, and diplomacy. They're also the organization that defends the Federation and is the one that fights the wars that need to be fought. That makes them a military.