When Star Trek was first pitched by Gene Roddenberry, I believe he said ‘Have Gun Will Travel’ in space (or some other Western). I just recently thought about how well that description fits.
First you have to get past the type of organization that prevailed in the Old West. The US Marshalls and their deputies, with the aid and sometimes detriment of local sheriffs and their deputies. The only regular military force was the US Army and they were a handful of regiments sent to deal with the Indigenous American ‘threat’. The well to do landowners, are a third force (with the wealthiest capable of fielding troops or squadrons of light cavalry, roughly thirty and ninety men respectively). Although, they were just as likely to serve as a manpower source for the aforementioned. Their ability to operate as a third force depended on the corruptibility and/or willingness of the deputizing official to work outside the constraints of the law. In any event this led to the predominance of small bands of men committing most acts of violence.
When you look at Star Trek, you have large vessels travelling the cosmos. Despite the ‘tall ship’ analogy waiting to be made, this is not Hornblower in Space or any other high seas adventure tale. The vessels, the Enterprise and those of the adversaries serve to get them planet side where the adventure occurs. This leads to so much action being performed by small bands of men and women. Thus making this a tale of a small few struggling, not just against the elements but adversity.
The Marshalls Service and Starfleet are different organizations. What then, is the common thread? It is in fact the similarity of the USA and the UFP (United Federation of Planets); for where the Marshalls and Starfleet are different, the UFP is a fair analogy for the USA. Or at least Earth is, with the other planets resembling the core of an international framework. Think of Tellar and Andor as Britain and France, not respectively. Vulcan could be Italy (formerly violent now dedicated to knowledge, arts and science) or perhaps Germany is a better fit (a formerly unruly people shaped by discipline and regimentation).
How are they similar? If you look at key hints like travel times( days or weeks between destinations); the existence of radio (instantaneous in system but not so in deep space e.g. the equivalent of message packets) and the big one the founding of the Federation. The Federation was founded in the mid-22nd century, approximately a hundred years before the series is set in the 23rd century making its founding correspond with the Revolutionary War. It is hinted that prior to the Federation, Earth went through Troubles (analogous to the Colonial Era). In this sense Vulcan can be seen as Enlightenment Era Europe supporting America, if only out of curiosity to see where she is headed. Fast forward a century and you have a Federation similar to 19th century America; both being centralized organizations with security/military/exploration outfits composed of the unorthodox, responsible for operating in an expanding frontier and tasked with keeping the peace. Two seemingly unalike settings that make for great storytelling.