Defense contracts aren't all weapons - in fact, I'd wager most aren't (by quantity, if not by dollar amount). Due to how the US allocates its budget, a large portion of its publicly funded research goes through DoD contracts. The startup I used to work at had a contract for making prototypes of multi-material 3D printers for creating medical training models (ie artificial cadavers).