MIT’s Lincoln Laboratory for example was originally opposed by the university president at the time with huge community backlash against the university becoming connected to a military research lab.
Part of the original charter of the lab was that its scope of operation was very, very strictly restricted to US air defense, and very strictly not the development of offensive capabilities. There was even a huge report commissioned by the university to detail exactly the defense needs and set boundaries around them in terms of what projects could possibly be approved for funding at the lab. The “no attack” component of this was a giant, first-order constraint of the whole multi-million dollar endeavor to even create the facility at all.
On the other hand, I do agree many other cases could be like what you suggested. Just saying not all.. and some of them would be directly, loudly predicated on “defense only” mandates where it would be a huge surprise if the research was subverted later.