First: you need to beware that there are two different sign conventions (rules for assigning + and - signs) that are used in different optics textbooks:
- Gaussian: Real objects and images have positive distances from the lens. Virtual objects and images have negative distances from the lens.
- Cartesian: Objects and images on the right side of the lens have positive distances. On the left side of the lens, they have negative distances.
(In both cases we assume the light travels through the lens from left to right.)
Some equations have + and - signs placed differently, depending on which convention you're using. The magnification equation you gave above is for the Gaussian convention. However, the diagram you included in a later post shows the Cartesian convention! (as evidenced by the "Note: object distance normally negative.")
In your diagram, h is a positive number because the object arrow points upward, and h' is a negative number because the image arrow points downward. Therefore M = h'/h is a negative number, which reflects the fact that the image is inverted with respect to the object.
Using the Gaussian convention, s is a positive number because the object is real, and s' is a positive number because the image is real. Therefore M = -s'/s is a negative number, in agreement with h'/h. The - sign in the formula is necessary in order that both versions of the formula give the same result.
Using the Cartesian convention, s would be negative, s' would be positive, and the magnification equation would be M = s'/s (without the added - sign).