Pathfinder took this sentence verbatim from the d20 System (under the OGL), which took it verbatim from Dungeons & Dragons v.3.5 revised edition (as the authors of the d20 System were also the copyright holders for D&D 3.5e).
However, the d20 System was pretty strictly limited to just the rules themselves—a lot of commentary, examples, illustrations, and so on were left out of the System Reference Document. Thus, the original context for this statement:
If a spell has multiple versions, you choose which version to use when you cast it. You don’t have to prepare (or learn, in the case of a bard or sorcerer) a specific version of the spell. For example, resist energy protects a creature from fire, cold, or other energy types. You choose when you cast the spell which energy type it will protect the subject from.
(Player’s Handbook, D&D 3.5e, 2004, pg. 170)
To my mind, however, resist energy isn’t the best example they could have chosen. To my mind, the best examples of spells with multiple versions are dispel magic:
You choose to use dispel magic in one of two ways: a targeted dispel or a counterspell.
Targeted Dispel: […]
Counterspell: […]
and greater dispel magic:
You choose to use greater dispel magic in one of three ways: a targeted dispel, area dispel, or a counterspell:
Targeted Dispel: […]
Area Dispel: […]
Counterspell: […]
When you learn or prepare dispel magic or greater magic, you get both (all three) of these versions. You do not have prepare targeted dispel magic or learn greater area dispel magic, you just prepare dispel magic or learn greater dispel magic, and cast it as whichever version you want.
Dispel magic and greater dispel magic also illustrate a case where things are not simply “versions” of one spell: that is, dispel magic and greater dispel magic are not versions of one another. They are separate spells. Related spells, of course, but separate, which means you do have to prepare or learn them separately.
Likewise, your examples of restoration and lesser restoration, and other qualifiers, such as the “mass” or “communal,” are not versions; those are separate spells.
In short: if it is one spell entry, with one set of school, descriptors, level, and so on, just listed within the one spell description, those are versions of one spell. Those are what the quote refers to. If they are separate spell entries, with their own name, levels, and so on, then they are not, and you need to learn/prepare those separately.