How to scale a rectangle along its length in one direction while keeping the stroke fixed in after effects?
In this situation I would right-click on the path options in your rectangle and choose "convert to Bezier".  Then instead of adjusting the scale, I would keyframe the path, and change the shape of the path in this way.