The terms confidential and privileged are not interchangeable, but they have closely related meanings that pertain to secrets. Both terms are, indeed, often misused when the other term would be the correct one.
If the information that has been provided to a person is confidential, either by virtue of the nature of the relationship involved (e.g. attorney and client, or psychotherapist and patient), or by statute (HIPPA information that a doctor's office encounters, or tax information that an IRS agent encounters, or grand jury information), or by contract (someone signs a non-disclosure agreement), then the person who receives the confidential information has a duty to not voluntarily disclose the information (without the permission of someone with a right to authorize the disclosure of this information).
Often someone with confidential information can't disclose that information even if the information has already been made public, because disclosing the information would corroborate its truth, while the source that made the information public might be an unreliable or not credible source.
In all U.S. jurisdictions, an attorney's duty of confidentiality arises from Rule of Professional Conduct 1.6, although, despite a uniform numbering system for these professional ethics rules for attorneys, there are important substantive law differences in the wording of this rule between U.S. jurisdictions, which are mostly related to scope of the "crime-fraud" exception to an attorney's duty of confidentiality.
If information is privileged, then a court can't compel the person who has the information to disclose that information, and a court can't allow that information to be used in a court proceeding, without the permission of the person who holds the privilege (usually, the person who provided the information or who is the "customer/patient" in the relationship). The term "privilege" in this sense of the word is also, more precisely, called an "evidentiary privilege."
In U.S. law, most evidentiary privileges are created by statutes or court rules, but a few arise at common law in some jurisdictions (including most privileges in federal court cases), and originally, all evidentiary privileges in the common law tradition arose from judge made common law.
Examples Illustrating The Differences Between These Terms
Lots of information that is confidential is also privileged, but not all information that is confidential is privileged.
For example, while information provided to a lawyer in confidence related to a client's case is both privileged and confidential, information that is covered by a non-disclosure agreement is confidential but is not privileged.
As another example, information a lawyer has about a client that is not obtained in a confidential communication from the client, such as information about a client gained from public domain sources, or information about a client obtained from opposing counsel in a lawsuit, is confidential, but isn't privileged. The lawyer can't voluntarily disclose that information, but a court can compel a lawyer to testify about or disclose that information.
Under data protection laws, there is a confidentiality duty imposed upon data controllers who are obliged to ensure there is generally no disclosure to third parties of data by which a subject may be personally identified. But, most data protected by data protection laws is not privileged. A court can, in most circumstances, order that a data controller produce information by which a subject may be personally identified in connection with a court case such as a criminal prosecution.
Sometimes information that is privileged is not confidential because the person who has the information does not have a legal duty to refrain from voluntarily disclosing it to others outside of court proceedings.
For example, if you told your ex-wife in private, while the two of you were married, that you had an affair with your teenage cousin when you were a kid, that is privileged information that a court cannot compel her to disclose in a court proceeding, or allow her to disclose in a court proceeding, over your objections. But you cannot sue her for violating a legal duty to you if she voluntarily tells one of her friends what you told her, and this damages your reputation or causes you to lose a potential business deal. She does not have a general legal duty to treat this information as confidential.
Situations where information is confidential but not privileged, or privileged but not confidential, often lead to serious moral or ethical or relationship dilemmas, even when no one's legal rights are violated.
Other Meanings Of These Words Distinguished
Of course, words have multiple senses, and often words even have multiple distinct legal meanings.
There are senses of the word "privilege" that are completely unrelated to confidentiality. An active duty soldiers has a privilege to board a commercial airplane before ordinary economy class passengers (as a matter of universal airline policy, not as a matter of law). A duke has a privilege to have an audience with a monarch. A diplomat has a privilege not to be arrested in the country that has received the diplomat. A parent of a minor has a privilege to approve or disapprove a request of a minor child to marry in many jurisdictions. But the other senses of the word seem to be beyond the scope of this question.
Similarly, the word "confidential" also has multiple legal senses, some of which are not related to not disclosing information. A "confidential relationship" is a non-professional relationship with a close friend or family member or advisor that is not rooted in any formal relationship of legal importance, which has nothing to do with keeping secrets. If you are in a confidential relationship with someone, you have a duty to not improperly exploit the confidence and trust gained in that relationship for your own benefit, even if you are not a true fiduciary for that person.