Use cedar shims (shingle) to plumb and level and square the vanity box. Then use 2 1/4" drywall screws or panhead screws to attach the upper back of the vanity to the wall studs, just 2 screws thru the back will hold a 3' vanity. Double check plumb/level adjust if necessary.
To put the top on just use a good bead of silicone Adheasive Caulking or building adheasive rated for the top. Fasten the top down with masking tape until the adheasive sets. Don't get in a hurry and try setting the sink trap at the same time. Wait over night, then caulk around the wall. DH