Potential energy of a spring vs potential energy of the spring-mass system

Potential energy is configuration energy: energy by virtue of the relative positions of the various parts of the system. So, as you imply, your textbook is quite right to stress that the gravitational PE of a raised block really 'belongs' to the Earth-block system, not just the block.

But in the case of a stretched spring the energy is due to the (increased) separation of the parts of the spring relative to each other, so the elastic potential energy simply 'belongs' to the spring as a whole – because it contains its parts! It would be confusing to bring in the mass.

One can sensibly talk about "the potential energy of the mass-spring (and Earth)" system when considering a mass hanging from a spring. This is because both elastic PE (of the spring) and gravitational PE (of the mass-Earth system) are involved.

What is the difference between potential energy of a spring and potential energy of the spring-mass system?

The latter is definitely the correct expression, the former is a rather lazy abbreviation.

We can understand this in quite an intuitive way with the following thought experiment.

Two fairly small, identical masses $m$ are connected by a spring. Now we separate the masses so that the spring is under tension.

This system, as a whole, has now gained potential energy. This is evidenced by the fact that if we release either mass it will start moving towards the other. Work is being done and potential energy is being converted.

Now we gradually increase the mass of one of the masses (say the left one), until it has reached mass comparable of that of the Earth. With each increase we repeat also the separation experiment.

It is self-evident that as the mass of the left mass increases and increases, it will be less and less inclined to move when released (because its inertia has increased so much). By the time it has grown to the mass of the Earth its movement will be imperceptible.

But the gradual increase of mass of the left mass doesn't mean it's not the whole system that has potential energy. It just looks that way for very large left masses because they don't move much when released.

The same reasoning can be applied for two masses and their mutual gravitational attraction.

Whenever you have one force, you always have another equal and opposite. Some of these forces convert one kind of energy into potential energy. For example, gravity. Two forces push Earth and a block apart, against gravity. If you remove the force, gravity accelerates the Earth and block toward each other. Potential energy is converted to kinetic energy.

A counter example is friction. If a block slides on the Earth, they exert forces on each other. They slow down and come to a stop. (The earth moves so little that we usually ignore it). In this case, kinetic energy is converted to heat, not potential energy. You can't get the kinetic energy back like you could for gravity.

So your text book is right. You store energy in a system where there are two opposing forces. But ...

A spring is like gravity. Two forces on the ends of the spring can compress it, storing potential energy in the spring. If you remove the force, you get the energy back. You really mean the system consisting of the spring and the things pushing on the ends. But it is common to talk about the potential energy of the spring.

Likewise, it is common to talk about the energy of a raised block.

It is important to understand the point, because you need to know how potential energy works. But it is also important to understand when people are doing physics right, even though they are speaking carelessly.

It is a little like English teachers getting picky about minor grammatical points. Except that sometimes the picky details matter. This is one difference between mathematicians and physicists. Mathematicians tend to be picky and exact. Physicists tend to be looser.

For mathematicians, theorems come from proofs. Proofs have to be perfectly correct and airtight. If not, a false theorem can be proven, and this can be used to prove other false theorems. It can literally bring down the entire structure of mathematics.

For physicists, laws of physics are statements about the behavior of the universe. It is often complex and impossible to get the exact answer. Physicists make approximations all the time. Sometimes in calculations. Sometimes in the laws them selves.