The idea of pressure remaining in the system is misleading. Pressure remains in the line because it was applied to move something, and it's the pressure that remains after that something has been moved. However, move the switch the other way won't provide adequate pressure to move anything. It will bleed to zero almost instantaneously.
Storage of pressure in a hydraulic system is accomplished with an accumulator. You can think of that like the magazine spring in a gun. Push more rounds into the magazine, and it holds them under spring tension (spring pressure), ready to push them back out of the magazine. A hydraulic accumulator works the same way. Internally, it acts like a one-way hydraulic acutator. You push pressure in one end, and the other end is filled with nitrogen pressure. You push a lot of hydraulic fluid in there under pressure, and when you need that fluid under pressure, you can open a and release it into the system.
Accumulators are necessary to "store" pressure. Accumulators are used to effect changes in gear, emergency braking and extention systems, unfeather propellers, etc. Accumulators also serve as dampeners in hydraulic systems, to absorb the jarring that sometimes takes place with the opening and closing of valves, or the sudden stopping of hydralic actuators (such as landing gear reaching full extention or full retraction).
Hydraulic fluid flowing to an actuator stays there. It stays there often under pressure, until the actuator is reversed. Again, fluid is squirted in one end of the tube, moving the plug to the opposite end. This fluid stays put until fluid is introduced on the other side of the plug at the other end of the tube...forcing the plug back. Valves are used to accomplish this.
Some valves are sequenced mechanically or electrically by other components. Sometimes limit switches are used to shut off pumps, or open and close valves. A common useage of both is to sequence landing gear doors up and down during retraction.
The pressure switch to which you referred serves to cycle the pump on and off. As pressure bleeds down, not enough pressure is available at the switch. This applies power to the pump, and the pump runs. Once the gear is where you want it, there is no need to keep running the pump. (On the ground, for example) The point of the squat switch, or uplimit switch cutting out the pump, is to stop the pump from running once the gear is in place.
Pumps have limited times, both in terms of life, and in terms of duty cycle. Too much running, not enough pump. That's bad.
Anytime you have the system sitting for any period, the pressure is eventually going to bleed off. Few systems are tight enough that they stay put forever. Pressure bleeds off through seals, etc. Therefore you have a pressure switch to cycle the pump on and off to keep the pressure up.
On the 172RG, the mains likely won't collapse if the gear switch is raised on the ground, as they must drop down a considerable distance, and can't raise the airplane up to do it. But the nose gear is another matter. It operates on an overcenter principle, and can collapse.
Other airplanes can completely retract on the ground. I've never witnessed it, but worked on a P2V that had that happen.