There are a few different common configurations of 4 way solenoid valves.
One design contains one liquid inlet and two outlets. In this case, the direction of flow is controlled by the position of the internal actuator. The other two ports, one on each end, aid in air pressure connections. As air pressure enters one end, the rod moves and internal channels allow the fluid to flow in one direction. If air pressure enters at the other end, the rod moves in the opposite direction, revealing a different flow channel that allows fluid to go in the other direction.
These 4 way solenoid valves are useful because they permit one device to control flow in multiple directions. Since one valve can be used for more than one control task, they are an advantageous purchase for a consumer whose control system only has a few connections available.