Well, they obviously couldn't buy them from Starfleet because Starfleet doesn't sell weapons. The Bajorans might have (and probably did) sell a few items out of their inventory but would have stopped after Starfleet leaned on them to deny those sales. A neural third party wouldn't give a shit, and there's not much the Federation could do about it except go on trying to arrest/detain/pacify the Maquis.I definately agree on the last part, as far as the former goes I'd argue that them not purchasing them through channels means that - at minimum - doing so, while not necessarily illegal as such - might act as a 'red flag' (similar to buying large quantities of legal substances used to make meth or ANFO would in the RW) without very good explanations.
As to your more specific point: this is basically what the Maquis did when they created their bioweapon to poison the Cardassians. They stole a shipment of cobalt, and then a shipment of selenium. I don't even think buying both of those things in combination would actually be illegal, but the fact that you can work those materials into a bioweapon completely lethal to Cardassians is an example of what I'm talking about.
An even better example is the bilitrium bomb Tahna Los was going to use to destroy the wormhole. It seems to me that there are quite a few of these nifty little "weapon of mass destruction" recipes floating around on the Federation Internet or something and it is shockingly easy for assholes, terrorists and lunatics to throw together a poor-man's doomsday device. Hell, even a hand phaser set to overload makes a pretty impressive bomb, and the kinds of guns that Quark's brother sells out of the back of his shuttle could be used to take out entire cities if somebody was motivated enough.
Technology has become the Great Equalizer in the Trek universe, so the utility of a professional military with combat-specialist forces probably isn't enough to justify the loss of OTHER capabilities that comes with having a multirole science platform carry those same weapons. In fact it might be just the opposite: professional militaries are inherently limited by their dependence on weapon systems and martial philosophy while more adaptable organizations like Stafleet can actually defeat most military forces pretty efficiently just by exploiting the weaknesses in their weapons and technology. The Klingons may be able to out fight you and out gun you, but Starfleet can hit you with a tachyon pulse that renders your weapons useless and then pump a sub-harmonic pulse through your sound system that turns your crew into a bunch of gibbering idiots; they win the battle without firing a shot.