Training, especially sparring in various forms, constitutes an exposure therapy of sorts. It is a process of gradual desensitisation, in which frightening stimuli are rendered less stressful via consistent, repeated exposure to the relevant threats over time. As the fighter adapts slowly to the sensations and reactions which accompany the experience of combat, the intensity and frequency of combat can be incrementally increased, until the flinch response has been replaced by more appropriate and relatively calm defensive and offensive responses.
Flinching is very close to defensive reaction. Flinching typically involves uncontrolled, unsafe, unreliable responses to attacks, whereas good defence of course channels that instinct into well-drilled, pragmatic reactions, including counter-attacks.
Let your coach know that you want to learn to spar. Once your understanding of the basics is sufficient, he or she will might judge it safe to allow you to do so. (Some sparring practices are much safer than others. Sparring can be a significant cause of Chronic Traumatic Encephalopathy (CTE), ie. brain damage*.
If you're a novice or otherwise unwilling to experience contact, distance sparring or 'mirror sparring' can be very useful. It is essentially no-contact sparring, in which you maintain a safe distance from your opponent at all times. This is a nice, easy way to get used to the motions of fighting without fear of getting hurt. It can help ease you in to the art of judging range, and can help you learn to recognise different punches as they are thrown, which is essential when trying to master your flinch response.
From here - the advice and supervision of a good coach is highly recommended - you can progress to very light-contact sparring. It's a nice progression, because now, there is 'something on the line' in that you will get hit and feel discomfort, stress and even pain, whilst the risk of serious injury remains low. Providing light contact is maintained, you will adapt to it, master the anxiety of being hit, and learn to channel your flinch reaction into solid defence (instead of into clumsy, dangerous and counterproductive evasion).
Once you get comfortable with light sparring, the intensity can be increased. Body-only sparring can be great fun, a great workout, and relatively safe, although if you don't train against strikes which target the head in some way (whether with contact or no contact), you will likely continue to react poorly to head strikes.
Once you have accumulated a lot of sparring experience, practice counter-attacks to further disinhibit yourself. Why? Counter-strikers learn to see an opponent's attack as an opportunity as much as a threat. An attack becomes less something to be feared than something to be invited and exploited.
If you continue to flinch at every punch, train yourself out of it by striving to master a sense of range, so you maintain poise even when a fist comes within half an inch of landing. To do this, develop a good sparring relationship with a fighter who has similar interests and who does not let ego and emotion interfere with the goals of intelligent training. Start light and slow. Build up to hard and fast. Drill one punch at a time. Spend 10 minutes learning to catch, parry or slip a jab with your left. Then another ten with your right, and so on. Again, a good coach is desirable here, or at least someone experienced who can provide sound feedback. It is also imperative that you and your partner know how to throw sharp, accurate punches which land, but do not penetrate. Mistakes will happen, but you should aim to minimise how often you accidentally hit someone harder than necessary. It will take a while. Be patient.
Once you've learned how much you can weaken an attack by countering it, confidence begins to grow. Consistently effective counter attack will often lead to your opponent's offence becoming hesitant, weak and ineffectual. This of course provides you with an invaluable psychological and tactical advantage.
As a more detailed example: If you teach yourself to be an excellent catcher of the jab, it ceases to become as much of a threat to you. You cease reacting with evasion and learn to use it as an opportunity to launch your own strike. The same can be said for kicks. A good counter-kicker can significantly reduce the efficacy of an aggressive fighter's roundhouse attacks by using quick inner-leg kicks which target the standing leg.
Once your opponent's confidence has been tempered in this way, they become more vulnerable, because their range, power and effectiveness has been diminished. This in turn has the effect of reducing your fear of attack, which in turn reduces your flinch response and frees you up to deliver your own strikes as effectively as possible.
High and medium contact full-body sparring is very dangerous. Even when good protective equipment is worn, the brain sustains impacts which can result in significant immediate and cumulative trauma. If you wish to become a competitive boxer, mixed martial artist of full-contact fighter of any sort, you are inviting injuries of this sort. Ask yourself if you really wish to inflict this damage upon yourself.
Martial arts, including self-defence, can be practiced in relative safety. If full-contact competition is not your goal, you might want to consider styles which do not demand regular high-impact training and combat.