Locate a suitable pair of studs in the wall behind or beside the washing machine with a stud finder. Mark the locations of the studs 48 inches above the floor with a pencil. Ensure the marks are on the centerlines of each stud by using the Deep setting of the stud finder.
Measure and mark with a pencil and straightedge a rectangle the size of the box, plus an additional working area below it of about 12 inches to allow you to cement your hookups. Cut through the drywall between the studs with a utility knife using the pencil marks as a guide. Remove the section of drywall without damaging it, as it will be reused once the washing machine box has been installed.
Unsnap and remove the outer trim surround from the front of the washing machine box. Position the box in the cutout section of wall so that the nailing fins on one of the vertical sides of the box is flush with the wall stud you wish to mount the box to. Ensure the outer edge of the box is flush with the surface of the drywall. Secure the box to the stud by driving 8d nails through the nail holes and into the stud.
Nail a strap bracket -- if supplied with your brand of box -- horizontally between the two studs at the top and bottom of the box with 8d nails, as this will secure the vertical side of the box that is not affixed to a wall stud.
Connect the hot and cold water supply lines and the drain line to the valves and fitting on the underside of the box, following the instructions that came with the box. Remove a knockout plug if present from the underside of the box with a flat blade screwdriver before installing the drain line.
Trim the original piece of drywall that you removed previously with a utility knife so that it will fit around the washing machine box. Screw the piece back into place with drywall screws.
Apply drywall joint tape over the seams of the drywall patch, then cover the tape with drywall compound, using a 6-inch drywall knife. Let the compound dry, and apply additional coats as needed (letting each coat dry) to create a smooth surface that's flush with the surrounding wall. Sand the compound smooth once it dries and paint the area to match the surrounding wall. Push the outer trim surround onto the washing machine box until it snaps into place.