Role of Military

The Defence Act 1990 makes fairly plain (section 5) what the armed forces are for. Namely:

(a) the defence of New Zealand, and of any area for the defence of which New Zealand is responsible under any Act:

(b) the protection of the interests of New Zealand, whether in New Zealand or elsewhere:
(c) the contribution of forces under collective security treaties, agreements, or arrangements:
(d) the contribution of forces to, or for any of the purposes of, the United Nations, or in association with other organisations or States and in accordance with the principles of the Charter of the United Nations:
(e) the provision of assistance to the civil power either in New Zealand or elsewhere in time of emergency:
(f) the provision of any public service

It should be noted the Act does not prioritise these roles.

Section 9 reinforces this as follows:
Subject to the succeeding provisions of this section, the Armed Forces may be used in New Zealand or elsewhere—
(a) to perform any public service; or
(b) to provide assistance to the civil power in time of emergency

Effectively as police constables where no civillian authority is present. There are limitations regarding industrial disputes and the length of time that defence force staff may be used under emergancy powers.
 
The ANZUS treaty was revitalised following the Wellington declaration  on 4 November 2010.

The defence force can legally be used for pretty much anything relating to the risks described earlier. The 1951 Anzus Treaty essentially does not obligate any of the parties to do anything specific except consult in the advent of an armed attack in the Pacific on any asset. The treaty is essentially defensive. The treaty does require the parties to maintain their own defences, though the relative scale of the American, Australian and New Zealand defence forces makes any notion of equality between them laughable.

The actual practical roles of the New Zealand military are somewhat different to the term "defence" and are better categorised according to the subpages below.