It was fighting both world wars against most of its closest trading partners... How did their economy continue to function?
Furthermore, why did the wars take so long to end with the amount of foes they were facing?
Perhaps you might be interested in the section Nazi economics of our Popular Questions (FAQ) which you can find on the sidebar. Especially this, this, and this thread should help answering your question.