Hamstrings are only part of long structure. Issue can be higher, or lower, or all together. Look for "superficial back line, Myers". As a prove - roll your feet - like here. Lacrosse ball is perfect for that. Then try if it help in your motion range. Most of us can do dead lift, squat easier.
Had same problem, and decide to stretch / mobilize - for two reasons - injury prevention, and moving exercise from edge of my motion range.
There is group of exercises that worked for me. They are done with door-frame. So you lie down with one leg rised on door-frame. That is the leg you are working on. Other one is slowly moving up, and down, or slides on the ground. All moves slow, with small tension. At start do that for an hour every day - note that you can do what ever you want with hands. Books, podcasts, what not.
The exercises are shown at this video, yes he is talking in Polish... Sorry for that. If you have questions, I can do some translations. He is naming exercises in English, but can't find them - by that names. Once again - sorry for non-English content, but that is something worked perfectly well in my case. Simple easy exercises, done with no pain.