I was you 6 months ago.
I had the exact same problem.
My problem was i was placing the bar to high on my back which was fucking me up. i lowered the
and made my stance slightly wider.
i also start by warming up my hamstrings with lying leg curls. Body weight squats, and stretching out my hips etc.
This helped immensely. I have added over 100lbs to my squat because of this.
I am not a pro whatsoever when it comes to squatting, but i have been where you are and
this is how i kinfa fixed my problem. Hope it helps.