yeah I think it's somewhat unconscious, like: for people with anxiety like this physical sensations can trigger panic attacks, it's not too uncommon for someone to have a lot of anxiety about health problems or heart problems and start to panic just from the physical sensation of their heart speeding up when exercising. or, could not even necessarily be triggered by worry about heart problems, but could be that they have enough panic attacks that their heart rate speeding up makes them scared that they're going to have a panic attack, so they panic about having a panic attack.
so perhaps Nick's body is so used to throwing up from anxiety that now when he has the sensation of food in his stomach, his body gets worried that it's going to have to puke it up, so it starts panicking which results in puking. so he eats and his body's like "oh no now I hate this feeling of food in my stomach because I'm worried I'm going to puke, better puke so I don't have to feel this anxiety."
I can also see it being kind of an addictive self harm cycle like bulimia, because he's saying his anxiety disappears right after he throws up. he could be semi-unconsciously continuing to pursue the feeling that will make him throw up just for the relief of the disappearance of the anxiety afterward. or like "if I'm not in the cycle of eating bad food and puking it up, I have more opportunity to get anxious about my actual life, which I can't get relief from by simply puking, I would actually need to improve myself and confront what a mess I've made of my life." plus as you mentioned, the satisfaction of being quirky or getting sympathy/attention for it.