Devil’s advocate, but parts of the Trek universe have shown that there are non- or quasi-sentient creatures capable of endangering starships like the Enterprise, in addition to the usual spacefaring hazards like asteroid belts and debris fields, and the potential to encounter, for lack of a better term, space pirates. It makes sense to arm the ship for a number of reasons not necessarily related to the power of coercion via the threat of violence. The Enterprise’s weapons are also frequently outclassed by other ships of similar size designed for combat. It feels more akin to packing bear spray or a noisemaker to scare off wildlife, and the bear spray gets used to drive off a robber.
That said, the threat of violence against a better-armed foe in order to prevent combat is a trope the shows rely on frequently, so you have a point.
Yeah yeah, listen buddy, I never wanted to live in interesting times, all I wanted was to be comfortable.