I’m no expert, and this may not be causing your hip pain, but:
Squat - you need to bend your knees and hips at the same time, not hips first then knees. I will say that I used to do that and had some hip pain as well, which has since subsided.
Deadlift - you seem to be exhibiting the classic step 4 error, where you drop your hips to set the back, and this kicks the bar forward. Freeze your hips on step 4, and instead squeeze the bar off the floor to set your back.