It can be due to rider error which creates training problems, or it can be a health issue.
If you are not asking for the turn correctly, and supporting your horse, some horses will give up and become reactive as the situation happens over and over again. I would talk to your coach or instructor, and ask them if there is anything you are doing that may be causing it to happen. If you are pulling on the inside rein when you should be using your leg to turn, some horses may react negatively to this. However, this is only one example. If you are riding a lesson horse, maybe find out if this is a common thing, or something that doesn't happen with certain riders. It's no reason to feel bad about your riding, but it does mean that there is room for you to learn from this horse, if that's what they are trying to tell you.
If there is no obvious reason for kicking out like this, and it has started relatively randomly, it is always recommended that you assess the horse's tack and overall health. If the saddle does not fit correctly, it can pinch or twist and cause pain, which can result in kicking out, and make a horse ring-sour over time. If your horse has any health issues that may not be externally visible, that could cause the same pain and discomfort and again, cause the kicking out.
I would talk to your barn owner, trainer, or someone knowledgeable and see what they have to say. There are infinite reasons for this, and infinite factors that can influence this sort of issue, so it's really hard to say from an outside perspective.
A horse can have many reasons to start riding: out of fear, because of an overflow of energy or even because of a discomfort caused by his harness or rider, or a problem on the back. In any case, a kick is very dangerous!
The best way to do this is to keep your calm going backwards, keep the reins taut and try to put the horse on small circles to precisely prevent it from continuing to kick and get carried away by itself! ! Do not stop the horse after a kick (even if one is in shock), we must continue to make it forward !! Otherwise the horse will say if I make a kick, I stop working, and he will do it constantly ...
To solve this problem you can try to make a "leg session" to re-learn the functioning of the leg to your horse and also to get used to react quickly if it starts again. But if it persists, you must take it to an osteopath, because it may be an important discomfort ...
I hope this helps, good luck !!