I think it is one of the common symptoms of being a writer. If you are sensitive and empathetic enough to be able to create alternate realities filled with realistic people in your novels, you are also more likely to suffer from anxiety and depression in your reactions to this life's input. It's not a given, but there is a bit of a trend. To write, you tend to remove yourself from others - so even if you are a really social happy person, your chosen career of writing can make you withdraw from a lot of that.
Also, our posture while writing is conducive to developing anxiety. Growing up, my generation were often told about the importance of posture, "sit up, shoulders back, straighten that spine, head up", and, in fact, there have been recent studies that indicate that our posture influences our character as much, if not more, than our character influences our posture. So, adopting the posture of a confident, happy, bold person (the sit up, shoulders back, etc, looking life in the eye, standing with arms akimbo in a Superman pose) helps shy, withdrawn, anxious people to become more confident, and it works the other way. So our posture while writing tends to be the posture of an anxious, withdrawn person - hunched over, folding in on ourselves, eyes down, protecting our torso region by having our hands in front typing. Consequently, that posture tends to make us more anxious and withdrawn. If you are by nature anxious, or feel that since writing you have become more so, whenever you take a break from writing, stand up, adopt that classic Superman pose (arms akimbo, head up, shoulders back, etc) and do it every time you walk into a new room - so, go to the kitchen to make coffee, and enter, stand like Superman for five seconds, then continue, same in the bathroom, bedroom, etc. Now, it sounds ridiculous, but it genuinely helps some of the anxiety our writing posture builds up.
Also - bad gut health and the lack anti-inflammatories are a huge percentage of all our physical and mental health issues. So, pro-biotics, pre-biotics (fibre - the stuff your gut bugs want to eat... pretty much, if it makes you fart, it's something they love), sauerkraut, yoghurt, vegetables, raw vegetables, fruit, and make up a brew of golden paste (just turmeric boiled with water and then coconut oil and cracked pepper added) and have half a teaspoon of that a day. Give the golden paste to your cat and dog as well - it makes them smell like cat pee until they adjust, but it adds years to their lives. If you have an aged dog that is beginning to creep around, after two days of golden paste, they'll be bouncing again - brilliant stuff. Tastes like crap to get down, but worth it.