muscle & body memory - if you stay in any position for long times, hours, days or years the body will start to think that is the "normal".
you need to counteract that forward head/forward shoulders posture.
One of the posture stretches I do is to do a reverse posture.
So if stooped, then you would exaggerate the leaning back and bringing your shoulders back and holding that posture for short times , many times during the day - instead of just trying to be straight only , go beyond that, if your balance allows it safely.
I also have some drawings of other ways to do a similar stretch.
The ball one depends a lot on your balance, so be safe if you try something like it.
Or lay on a large towel rolled up tightly - pillow if needed for neck comfort - then just relax with arms at a comfortable position and let gravity lower your shoulders down and allow the back to straighten.