As someone else mentioned, lawyers often try to use treating clinicians as a backdoor forensic eval, even going through insurance for it. They tell their client to go get a personality assessment, and then turn around and use that in their child custody case. This is why understanding the referral question and documenting it in the report is so important. I get a handful of inquiries every year of people looking for a "TBI evaluation", but really they want you to go testify that you think they should have custody of their child, tell the court they are disabled, etc. The lawyer can then subpoena you to testify about your report. There are things you can do to mitigate the chances of them doing this, but some will still try because using a treating clinician is MUCH cheaper than them hiring an actual expert. Depending on the jurisdiction and case law, they might not even have to pay you that much to do it.
The above example is why I don't generally accept self-referrals without really looking into it first and sussing out what they actually want. Even with referrals from clinical providers, I still pre-screen EVERY TIME because lawyers can use shill providers to make it look like a clinical referral and get it paid for through insurance. Pretty quickly you learn who are the shill providers and letting them know you won't take their referrals usually works. This can actually be fraudulent if the assessment is specifically meant for court and not medically necessary, but that's between the insurance company and the patient, and it is rarely if ever pursued.
I also put in my intake paperwork specific language addressing backdoor referrals and how clinical work and forensic work are different. I always go through my intake forms with each patient (or client, if forensic) and make a point to review the litigation section in detail so they understand the differences between patient v client, and my role in each scenario. I also go through the financial section to ensure they understand that they are on the hook if they mislead me. There are instances where a patient sees me for a clinical reason (e.g. workers comp injury that required a chronic pain assessment) and then their lawyer uses their report as part of their legal case, which is totally fine because there was a clear injury, the assessment was medically necessary, and it was part of treatment. In that scenario, I am the treating clinician, and the paperwork CLEARLY reflects all of that. There are things that I can do in response to any subpoena to squash the amateur hour backdoor attempt, but most lawyers don't want to poke the bear once they realize I'll cause them problems, up to and including notifying the judge and/or filing a Bar complaint. That has only come up a couple of times in over a decade of practice, but that's due to me always screening and being pretty conservative with every forensic case I review.
The vast majority of cases this stuff doesn't come up, but newbies are much more likely to get dragged into a case because they don't know any better. Lawyers will look for a sucker because the lawyer is the one footing the bill, so the clinical rate is 1/3 or 1/2 of what the forensic rate would be, and they can avoid paying a retainer, etc.