Good question. That's a philosophical question, believe it or not. The Rolling Stones said "You can't always get what you want, but if you try sometimes, you might find, you get what you need."
It only seems to be technical, or better said it only seems to have a technical workability, but in fact it regards life in its wholeness. People behave in the same manner irrespective of their status, if they are holding an iPhone in their hands or are on the verge of taking a life-changing decision. They can easily confuse what they want with what they need.
In business, if you offer them what they want, you will sell, but on the long term you will lose credibility as soon as they realize that your product is not what they need.
If you offer them what they need, they might not buy.
It's a headache, but it can be solved through fantastic user research techniques.
Another way to address this issue is to proactively develop a copy that tells them that your product is precisely what they need, even if they might think otherwise. Which they do. Therefore, anticipate the whole rhetoric of their mind that negates your product and tell them the truth:
"No, you actually need this... because... so..."
In order to do so, you need to identify the way they fool themselves into buying candy instead of broccoli, then schematize the way they rationalize the truth and counter it with psychological persuasions, expressed in your advertisments.
So, the short answer would be the eternal one: user research and marketing.