hey dude you have to do an intense work of stretches.
with a predetermined program of stretches you can improve this in up to 3 months, that is lack of mobility.
We end up causing this by the fact that when we can not make the movement, we do not repeat it and not even insist much on it, simply by limiting itself in that movement, which aggravates this mobility more and more.
in my case, I'm 28 years old and I say to you until I'm 27 I've never been able to stretch my hamstrings a lot, and I decided to try to improve it because it hurt my squats too, so in 3 months of correct and intense stretches I can already touch the ground, hands reached just below the knee.