They were under the DoD, but they filled a role closer to the NSF today.
DARPA was defense projects funded by the military for the military. NSF predates DARPA by 8 years. DARPA did not fill a role closer to the NSF today.
It was after ARPANET was created for the military that it was expanded into general university use by NSF into NSFNet in 1986.
(I worked for Bob Kahn and Vint Cerf in the early 90's.)