It’s a trope that appears multiple times, but most of them are called to as monkey’s paws. They give you exactly what you wish for at first. Each successive wish is twisted and normally ends poorly. It can also be used to convey of meaning that what you want is not what you need.