It is true that we'd need a video of your performance of a punch - only then can earnest troubleshooting begin.
That your instructor allowed you to go 5 years, and not once provide guidance on how to stop it, raises a serious red flag as to the effectiveness of the instructor. Raising shoulders is a beginner's mistake, and most will correct it in due time. For them, it's all in technique. It is the same for you, except now you have to fight habit. Whatever you are told to do to correct, it will feel unnatural to you, because you are so used to the bad habit: this is one of a myriad reasons why finding a good instructor is so critical.
As to lifting the shoulders, that is not necessarily a wrong thing to do. For a beginner, I'd say yes - don't do it. But boxers do it, and have good reason to cradle the head into the shoulders. The technique there is related to the sport, the rules, and the equipment, and so probably doesn't apply to you. You can certainly use the shoulders to block or deflect as a boxer does, but you should first learn to do it without cradling.
When my students do this, it's almost always tension: they are told to punch, and so, they think they have to punch as hard as they can, so, their body internally winds up (resulting in the shoulder lift). To help them get out of this habit, I always tell them that for them, they should never think about punching hard. Hard punches come from speed, and with speed comes time and patience. So, they should think "less power". It takes a few tries, some even go though a phase of almost slow-motion punches; eventually, they get it.
For you, perhaps you'll need two trainers to help you break the habit. Have one hold targets (or use a punching bag); the other stands behind you with either their hands on your shoulders, or with elephant ear targets on your shoulders. This will help remind you to keep your shoulders down, and to slow down, and to relax.
Next up is the hips. Are you fully turning your punching side hip into the punch? Doing so can lead to over committing your body into the punch, but too little can make you look like a rigid robot, and neither will help you. You should rotate your hips, which will facilitate torso rotation which will facilitate shoulders moving slightly forward.
Next up is the head. In this case, rather than thinking to keep your shoulders down, rather, think about keeping your head up. This change in focus may help to lower the shoulders.
Next up is the chin. With chin tucked, as many beginners do, that will inevitably lead to shoulders rising. Keep your chin up. But not so high that you end up reaching for a target. Your head should be perfectly balanced on the shoulders. If you used no muscles to move or secure your head motionless, then, that is the position your head - and chin - needs to be.
Also with the chin: take note of where your nose and chin point. If your head is cocked ear-to-shoulder, it means you are reaching. If you focused on keeping the chin and nose always pointing toward the target, and not cocking the head to one side, that should help keep the shoulders down.
Last up is the brain. People lift shoulders for psychological reasons - usually fear and anger. It is less likely you are feeling anger, but fear is possible. Some people freeze when it comes even to friendly sparring. If you like to spar, this is probably not your problem, and if you've been at it for 5 years, it's very doubtful this is your problem. But the rest of your body will be telling: do your feet move in a haphazard way? Are you always moving back? Do you gallop a lot? Do you crouch your torso behind your guard? If any of these is a "yes", then you might have a psychological problem to sparring. If this is the case, relaxation is key. But telling people to relax is not helpful: most get it. They just don't have the means to relax, and there are many. Think that you're not there to win matches; you're expected to take hits and not be afraid of them. You should be taking hits. So accept them. Even invite them. Get the body to stop thinking "OMG! OMG! OMG!" and start to think "lets move with purpose". Think "sway". Think ballroom "dancing". Just relax. Take hits, and invite them. Your partner is not there to hurt or intimidate you. And work with your partner and tell him or her this: you're working on body relaxation, so, don't expect much.