A lawyer's duty runs to their client. It can also run to a genuine intended beneficiary of the representation: someone the lawyer was working to benefit, like a named beneficiary under a will the lawyer drafted. It does not run to the other side.
The rule
Lucas v. Hamm, 56 Cal.2d 583 (1961) is the foundational case: an attorney's malpractice duty belongs to the client, or an intended beneficiary of the representation, and not to anyone who happened to deal with, or be affected by, that representation. Jane Doe v. Goldrich & Kest Industries, Case No. 25STCV33104 (Los Angeles County Superior Court), applies this line cleanly: a tenant sued her landlord's own law firm, claiming she'd been confused about who the firm represented. The court held that an opposing party, however confused, isn't a client or an intended beneficiary, and sustained the demurrer. The claim was closed on the pleadings, not on the facts of what the firm did.
Why "I thought they represented me too" doesn't work
The rule turns on who the lawyer owed a duty to in the first place, not on how the lawyer behaved. A confused or even mistreated opposing party has other potential claims (against the other party, for instance), but not against that party's attorney, because the duty never ran to them.
The bottom line
If you're on the opposite side of a case from a lawyer, and you're considering a malpractice claim against that lawyer specifically, check one thing first: were you ever their client, or a genuine intended beneficiary of their work? If not, this path is closed, because of who the lawyer owed a duty to, whatever the lawyer did.
Methodology note: illustrated by one real California trial-court ruling (Case No. 25STCV33104, Los Angeles County Superior Court), a non-precedential tentative you can look up on the county docket, cited here for its own binding authority (Lucas v. Hamm), which is the published, citable law. This is a statement of established doctrine, not a corpus-frequency claim. Nothing here is legal advice.