From the wikipedia of V-2 Rockets:
> The world's first large-scale experimental rocket program was Opel-RAK under the leadership of Fritz von Opel and Max Valier, a collaborator of Oberth, during the late 1920s leading to the first manned rocket cars and rocket planes,
Looks like rockets were invented before a global war broke out with peaceful intentions, then the military used that invention for violence, as a global war broke out.
Just because an invention is used for war doesn’t mean it required one to be invented.