The gravitational force is acting downward as the spring is held vertically. Therefore, spring is stretched downward and the force is directly proportional to the stretched distance. The product of the mass and the gravitational acceleration gives gravitational force.