Experts in a particular field can help us add a sense of realism to our works. I'd add that a writer should be mindful of who they're asking and what they are asking. And never, EVER take advantage of an expert for personal use.
Yes, this comes from personal experience. For a long time, I didn't mind other writers asking me legal questions. Unfortunately, I almost got my butt burned once.
A particular writer asked a particular question pertaining to a particular criminal charge against her character. Now I can talk theory with the best of them, but I've never been either a prosecutor or a criminal defense attorney. I gave this person a rough outline of what the character could expect, and if she had any further questions, I could refer her to a friend from law school who practiced criminal defense law.
A few weeks passed, then I got an odd call from Lanelle. Yeah, my criminal defense friend.
Another attorney had complained to her about a client's relative going behind his back and seeking legal advice on his client's case. He'd checked on this alleged wrongdoer poaching on his territory and found out she was some probate attorney named Suzan Harden. Even worse, he planned to file a bar grievance against me.
Luckily, Lanelle defended me to her fellow criminal defense attorney and told him she'd call me to find out what was going on. Once she explained the details, I knew the relative in question had been the writer. I thanked her profusely for letting me know and called the other attorney to apologize.
And refused to answer to any more legal questions from writers beyond my immediate critique group.
It sucks to have to be this way, but I can't afford a lawsuit for malpractice, much less defend myself against a charge of unauthorized practice of law since I let my law license expire a couple of years ago.
So keep this in mind when you ask someone for help. Someone is giving you their time and experience to make your writing the best it can be. Don't stab them in the back trying to get a freebie.