I have had back pain caused by squatting with APT (also read as bad form). I also butt-wink if I try to go too deep on my squats.
What helped me get out of pain and squat without pain:
(1) Dr. McGill - leading expert in the lumbar spine. I use his Big 3 core exercises as much as possible (every workout) to strengthen and stabilize my core. http://www.backfitpro.com/pdf/selecting ... rcises.pdf
(2) Goblet squats - Goblet squats are one of if not THE best tools for learning to squat with correct form. Use them to teach yourself to keep your back from rounding or extending too much. Play around with stance width and foot angle. While the butt-wink can be caused by mobility restrictions, it can also be cause be caused by the way your hip socket is shaped. Whether or not you need a wide or narrow stance to squat to/past parallel without a butt-wink is generally dictated by your hip socket. Also, some people just can't squat deep. I posted a link on reddit a while ago: https://www.reddit.com/r/weightroom/com ... s_optimal/
So, use the goblet squats to find the best way for you to hit depth without the wink. Don't squat past the point your back starts to round. You should be able to progressively get deeper the more you squat.
(3) Low bar squats - low bar squats require minimal ankle flexibility and proper depth is getting just below parallel.
(4) Raised heels - using either weightlifting shoes or plates. This will give you more ROM before you butt-wink.
If you do have APT, then stretching your hamstrings is not the correct approach. It will only make your issues worse. Focus on core strength, glute and hamstring strength, and patterning your squat and hip hinge movements.