I know that it provably has to be away in other territories, but what are some other factors and examples?
E.g WWII was a net benefit to the US economy and pulled us out of depression. Vietnam was a huge loss and didn't really gain much (besides scientific research?)
There are two principal factors: unemployment and underemployment at the start of the war, and what I'll call war devastation, the combined damage to a country's infrastructure and its population.
The United States entered World War II on the heels of the biggest spike in unemployment and underemployment in its history. This meant a large population was not, before the war, contributing to the economy.
During the war, the United States did not suffer war damage. It was not bombed on a significant scale, and compared to other combatants did not suffer a large number of casualties. This meant that infrastructure investment during the war was not offset by wartime damage.
Now, there are two predominant theories as to the best way to bring a country out of a recession or depression. Please consult an economist before trying this at home.
One theory says that the best way to get out of bad economic times is to cut spending and taxes, thus reducing the government burden on private enterprise. The second theory says that governments should spend widely, even if it means running up deficits. That's because governments can borrow money at times when private enterprise can't, and the deficits will naturally fall as the economy recovers.
The second approach was favored by Franklin Roosevelt, first in the New Deal, and second as the war arrived. Massive spending in the Two Ocean Navy bill and the militarization of the U.S. Army and Army Air Corps boosted the economy of the entire United States.