In the case of the J-box on the tugboat, I could see two things that might help. First, the box was located where it was bound to get wet (from water over the bow and from pressure hoses used to clean the deck). Relocating the box to a less exposed area would surely help. Second, the box lid was a simple flat plate held on with four screws. It's a very popular box for shipboard applications, and a flat plate cover is cost-effective, but probably not the best design for the problem. A lid with flanges that protect the gasket would prevent water from the pressure hoses from impinging on the gasket. The box isn't really rated for high-pressure water jets.
For the project two months ago, the water came from a proportional valve with an I/P (current to pressure) converter, which controlled high-pressure hot water. Faulty check valves permitted the water into the air lines, into the I/P converter, through the electrical conduits, and into the enclosure. I suppose in this case all of the enclosures, fittings, and conduit actually performed to specification. Water did not enter through them.
The shipboard J-box wasn't rated for pressurized water jets. Faulty check valves let water pass through an I/P converter. Operator error permitted water into the enclosure.
Selecting the right components for the initially specified conditions may not suit the reality of the installation. Improper installation either at your machine or other equipment connected to yours can still let the environment in. Using components rated higher than necessary will affect the bottom line of your company, and yet you must still plan for expected misuse. Maintaining the separation of the environment from your machinery is a challenging balancing act.