As a thank you for the people hosting a party I brought them a little present. They said:
"Danke schön! Das wäre aber nicht nötig gewesen."
Shouldn't I have given them anything? Did I do something else wrong?
It's a phrase to express gratitude. It is an indirect acknowledgment that you intended the gift as a gift, and not for satisfying a perceived necessity ("nötig" comes from "Not", English "need" or "poverty").
The confusion probably comes from the literal translation "That was not necessary / unnecessary", which, as I understand it, is a defensive remark to an attack or insult of sorts.
Edit: The more idiomatic translation and English equivalent is probably "Oh, you didn't have to!", in a positive meaning.
It's just a polite phrase meant to convey that you in no way expected to receive a gift, frequently used even by people who did in fact expect one, but want to appear polite. The English equivalent is "Oh, you shouldn't have!"