By painting MDF like any surface, you help to create a film on the surface that can resist some level of moisture. While painting MDF doesn't waterproof it, it does help to prevent water damage. To fully waterproof MDF especially if you are using it outdoors, paint it with a dedicated water-repellent.