It's normal to experience pain when stretching. In fact, a large part of increasing flexibility is gradually increasing our tolerance to the discomfort of this type of loading.
We feel pain when we stretch because our bodies are sensitive to interpreting less common inputs as potentially threatening. When we train flexibility, we attempt to move into ranges that are unusual for us. New sensory inputs that arise (mechanical, thermal, and chemical) are perceived as potentially dangerous by our central nervous system (CNS), which is wired to be protective.
Our thoughts, beliefs and previous experiences associated with danger and damage heavily influence our pain experience. If you have been injured or believe that stretching is damaging, you are more likely to experience pain. This effect will be magnified if you believe injury will result in significant compromise to your occupation, lifestyle and relationships.
In healthy, uninjured tissue, pain is not a good guide to stretch intensity or safety because it doesn't directly indicate damage or threat to tissue. We can experience pain without harm, and we can sustain injury without feeling any pain.
Pain is also a poor guide to stretch intensity because it's subjective and influenced by many factors. For example, we tend to be more sensitive to pain when we are sick, tired, in a bad mood, prior to a menstrual cycle, or injured. It's one way our CNS gets us to take it easy. For this reason, subjective ratings of pain will vary from day to day, even if we are doing the same stretch.
It's common for coaches to refer to 'good pain' and 'bad pain'. However, dichotomising pain like this is unhelpful as every person's pain experience is different. The perception of pain depends more on the context than anything happening in the tissues. 'Good pain' is a strong input that we perceive as beneficial, usual, expected and potentially rewarding. Some people can even experience a sense of elation similar to a 'runner's high' whereby the CNS reward centres are triggered to release endorphins, endogenous opioids and endocannabinoids associated with euphoria, reduced anxiety and reduced ability to feel pain. In contrast, 'Bad pain' is a strong input perceived as threatening, potentially dangerous or damaging. We tend to experience 'Bad pain' when we load 'valuable tissue' (eg nerve and joints), at end of range positions and in new ranges.
Sometimes coaches forget how uncomfortable flexibility training was for them when they first started and may tell you it shouldn't hurt at all. Moving into new ranges always hurts. Unfortunately, we can't avoid experiencing pain when we are challenging ourselves. Pain isn't a bad thing or something we need to avoid. We need to listen to our bodies, but pain is never the only thing that should be considered when stretching or loading tissue.