I suspected this and was surprised to find studies that actually demonstrated it. Of course, it’s not an experimental study, so we can’t tell whether depressed anxious people are more likely to become vegetarians, or eating vegetarian makes them that way, or a little of both.
However, I ate vegetarian years ago. When I started eating meat again, I noticed an large but unexpected boost in my mood. So the idea that a vegetarian diet could be causal is plausible, at least in some people.
Full text article: https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0088278