Do you warm up? Sometimes if you don't warm up and start doing hard things, sometimes you can feel some pain I guess. Try to play some exercises before you start practising, and when when you feel your fingers warmed there you go.
Often with fretting hand injuries/issues such as tendon based tension and overexertion , a primary cause can be overspending on the fingers to manage fretting, stretching/squeezing (less than one finger per fret, an Am shape is a good example of this particular hand position) and position changing without considering other biomechanics options that we have available.
Try using the thumb of the fretting hand as a pivot point for movement from the elbow and wrist. Use these moments whilst minimising the amount of movement generated from the finger joints to guide the fretting hand fingers into their desired positions.
Perhaps move the position up the neck a little to where the stretch is still a challenge but doesn't cause any pain, slowly working your way back down, fret by fret, to the origibal position over time.