Australia and New Zealand were both considered likely potential targets for Japanese invasion if the Japanese expansion campaign in the Pacific had proceeded according to plan. But more importantly, they were logistical and operational hubs for waging an incredibly challenging war over thousands of miles of sea and island archipelagos.
In large part, Japanese imperialism in the Far East — the 'Greater East Asia Co-Prosperity Sphere' — was driven by a desire for Japanese hegemony, and correspondingly for the removal of Western influence. Australia and New Zealand, as Europeanised countries and important members of the British Empire (albeit both increasingly autonomous by that point), were squarely in Japan's crosshairs.
In the event, NZ never came close to invasion. A mooted invasion of Australia (which would likely have to have been a precursor to invading NZ) never made it into the strategic planning stages. But the war came closer to both countries than either was comfortable with: Papua New Guinea was a major battleground in 1942; the Solomon Islands were the scene of intense fighting in 1943.
The other factor is that Australia and New Zealand, as allied, industrialised countries made them highly useful staging grounds for waging a large-scale, logistically complex air, sea and land war in the Pacific.
After the initial phase of Japanese expansion in the East — the attacks on Singapore, Hong Kong, the Philippines, the Dutch East Indies and French Indochina — the three most reliable and defensible areas under allied control from which war could be waged were unquestionably India, Australia and New Zealand. New Zealand is certainly the least important of the three (because of its size and geographical location) but it nonetheless had a role to play.
This site, run by the New Zealand Ministry for Culture and Heritage, has a really good overview of NZ's role in the war. You can also read The Official History of New Zealand in the Second World War and accompanying documents at the Victoria University of Wellington's website.