It is commonly spread within hospitals and rest homes.
However, Waikato District Health Board says an internal investigation found some of the babies already had the bacteria on their skin before arriving at the hospital.
The NICU treats infants transferred from other regions as well as other locations within the Waikato, the DHB said.
"We routinely test all infants coming in from other districts for a number of conditions, including MRSA."
Waikato DHB hospital and community services executive director Sue Hayward told a hospital advisory committee in late September that several babies had to be moved from the unit because of the superbug.
At that time five of the babies who tested positive remained in the NICU, which provides treatment to a range of premature babies with different needs, along with full-term infants born with serious conditions or injuries.
Staphylococcus aureus is a common bacteria found on the skin of about one-third of healthy people.
It is transmitted through contact and is generally harmless, but some strains can develop resistance to common antibiotics used to treat skin or wound infection – which is then called MRSA.
The DHB told Local Democracy Reporting that infants with MRSA on their skin, known as colonisation, generally do not get sick, with the bacteria eliminated naturally over time in most cases.
"During the outbreak the hospital identified 24 babies and 12 mothers who were positive for the bacteria, with further investigation indicating that some babies had been colonised prior to arriving at Waikato Hospital.
"Four infants and four caregivers showed signs of the bacteria and all were successfully treated.
"Infants who tested positive were isolated. A number of staff also tested positive and were provided decolonisation treatment."
The DHB said the newborn unit followed national and international infection control protocol during the outbreak, which included visitor restrictions and extra hygiene measures and testing.
"The families of patients in the unit were informed and provided with appropriate PPE and further hygiene protocols to follow when they visited their babies.
"Ensuring patient hygiene and that anyone who has contact with them follows good hand hygiene practices is the most effective means to prevent spread.
"The NICU already follows strict hand hygiene protocols, however, MRSA transmission often occurs through skin contact such as hugging."
The four infected babies were moved out of the NICU and isolated within Waikato Hospital.
The DHB said the outbreak ended after eight weeks of no new positive cases identified, on November 10.
"MRSA is an ongoing concern for hospitals as it is a common and easily transmitted bacteria which is found in a high proportion of the healthy population."
In May a mother tested positive for MRSA after giving birth via caesarean section at Auckland Hospital during the level 4 lockdown, the NZ Herald reported.
In 2016 a premature baby in England died after contracting the superbug in a hospital maternity unit.