how solenoids work

A solenoid is an electrically-controlled valve, it converts electrical energy into mechanical energy and permits for remote, and autonomous operation of a valve. The mechanism varies from linear action, plunger-type actuators to pivoted-armature actuators and rocker actuators. Since LPG systems use plunger-type systems to regulate the gas, we'll focus on that.

In a sailboat LPG system, the controller is placed inside the cabin and the two-port valve is operated remotely from there, without having to physically open the tank outside. Some controllers are equipped with automatic shut-offs, triggered by a sniffer when detecting leaks in a system which will send a signal back to the controller to switch the valve off.

When the controller is turned on, the controller sends a signal to the valve to open it. There are two types of valves:
Normally Open - N.O. and Normally Closed - N.C. .

In LPG systems N.C valves are required, so that if the power source goes out the valve closes.

Screenshot from Solenoid Basics Explained(YouTube) by The Engineering Mindset.

With N.C valves, the flow of gas is obstructed by a metal plunger, with a spring forcing it into a closed position. The plunger and spring are contained within a large copper coil. When current is applied to a straight wire, the magnetic field moves in a circular pattern around the wire, but when the wire is shaped into a coil the magnetic field intensifies and is concentrated in the center. This magnetic field causes the metal plunger, attracted by the pull of magnetic field, to slide upward against the spring, opening the valve and allowing the gas to pass. When the current is turned off, the magnetic field collapses and the spring forces the plunger back into its original resting position.