Air is intended to enter at 4 main points; the two "hand holes" in the sides, under the front of the seat, behind the gas tank, and under the back edge of the seat.
At the front, there should be a mud flap that lays against the top of the back of the gas tank and down along the top of the frame to about where the shock is. If you don't have one, make one.
Unless things get really crazy, there isn't too much of a problem with water coming through the side holes. Most of that happens at low speeds. The back fender and seat can be a problem. Quite a lot of water can run down the fender under the seat. Then it runs into the back of the air box. Some people tape pieces of cord or fuel hose onto the fender under the seat so that it makes the shape of an upside-down letter "V", pointing up and toward the back of the bike. That keeps most of the water moving off of either side instead of running down the middle.
Remember that YZ air boxes have open drains. If you get them deeper than the bottom of the box, water just runs in.