Notice when removing an old, wooden countertop that tabs at the upper front edge of the dishwasher are screwed into the counter top. Before installing a new granite top, you'll need to provide for something these tabs can be screwed into. If installing a new dishwasher, again note the tabs and plan for something to screw them into.
The tabs keep the dishwasher from tilting forward when the door is opened.
Think ahead when building new cabinets for below the granite top---or when installing new cabinets. Plan for a 5/8-inch or 3/4-inch board to lie on top of the dishwasher and under the granite top. It needs to be only two to four inches wide. Stain or paint the front edge to match the cabinet facing. Nail the board in place or epoxy-glue it to the underside of the granite using spring clips to hold the board in place while the glue dries.
Epoxy-glue mounting brackets to the under side of the granite or screw them to the side cabinets. The dishwasher tabs can be screwed to the under-granite brackets, eliminating the need for a board on top of the dishwasher. With side-mounting brackets you don't need a washer-top board, either.
Screw the dishwasher tabs to the board or the under-the-granite mounting brackets. With side-mounting brackets, you don't need to bother about the top-of-the-washer tabs. Open and shut the dishwasher door to ensure the unit is being held in place.