I
"With rare exception" means they do build warships, then. And the rest of the time, apparently, they have non-warships which are perfectly capable of fighting in wartime action. If they are not designed for that capability, it is a truly wonderful coincidence that they are able to function well in that unintended role. As I said, it's a word game. What's more interesting to me would to be a look at why the Federation came to adopt this obvious fiction.
Starfleet ships are highly modular... Meaning they can be adapted to different functions depending on mission requirements (but standard configuration usually comes with powerful shields and weapons - which don't detract from the point its a ship of exploration).
This is why even though they aren't designed to be warships, they would be perfectly capable of fighting in wars... Because they can be modified for that function if the need arises (albeit for wars... existing/standard configuration may undergo a few modifications to make it better at it - such as what Jellico did when he was on board Enterprise-D while Picard was away briefly).
Looking at the Defiant for example... That ship simply sported newer technology (which found it's way into other SF ships)
Otherwise it was unremarkable. New yes, so its going to sport newest forms of technologies (which again will go into other ships when its their time to be upgraded).
You think a Galaxy class cannot be adapted with same weapons firepower output of the Defiant through regular phasers and better shields for example? Of course it can.
Starships regularly undergo upgrades as time goes on... a lot of the upgrades can be done in the field, and some of it is done is spacedock if a ship returns ahead of schedule - though to be fair, the computer could be set to automate this process entirely via transporters, replicators, tractor beams and antigrav fields fairly easily.
Remember the USS Lakota? That was an 80 year old Excelsior class ship which was upgraded with modern technology and ended up rivaling the Defiant (but was probably faster than the Defiant when it came to warp speed - actually when you think about it, the Defiant was really slow compared to most other ships - and it was one of the limitations Starfleet will need to correct - maybe equip it with more powerful/adaptive structural integrity fields).
Also, technically, if the Lakota was given ablative armor like the Defiant, the Defiant would have been disabled as opposed to that fight reaching a standstill.
My point is that a Starfleet ship can fulfill a role it's given if modified accordingly because of the modularity it has (however, we've seen time and again that Starfleet ships come in a standard configuration which makes them fairly adequate for any number of tasks... think of it as a 'baseline' which the crew then continually improve upon - similar to what was done on Voyager).
It's not a military vessel though. Primary purpose is exploration, discovery and diplomacy.
Defense and offense only when necessary and only if there is no other choice... But I don't think defense/offense is an excuse to label it military when it's a function that Starfleet doesn't like to employ and is there to increase the chances of survival when it comes to space travel (phasers and torpedoes/ shields are frequently used as precision tools for scientific purpose).
Sure, Starfleet also employs protection/defense of Federation space, but that's not unusual for such an organisation (especially when its surrounded by potentially unfriendly species).
Having a ship without shields or adequate hull resiliency/armor leaves the ship susceptible to being ripped apart by an anomaly (something that Starfleet frequently encounters) or potentially hostile alien vessel.