Nail polish works by forming a solid, impermeable layer on the nail. This layer prevents water, as well as other substances, from penetrating the nail itself.
However, there are some nail polishes that are specifically designed to be *resistant* to water, offering a longer-lasting manicure. These are often called "waterproof" or "long-wear" nail polishes.
Let me know if you have any other questions!