Cabinets these days are built fast and cheap. If you are lucky, solid wood will be used for the door frames, but he cabinet body will be a particle board material or other relatively inexpensive material. The backs of the cabinet will be ultra-thin, so thin that if you tried to install a screw through it, it would probably tear and the cabinet would fall. For this reason, cabinet manufacturers put a thicker piece of wood at the top and bottom rear of the cabinet. This is so you can screw them to the wall and they will stay.
Use cabinet screws to hold them in place. These have a larger head for more bearing pressure. If you are installing a row of wall cabinets, it’s easy to get them aligned if you first screw a 2″x4″ to the wall where the bottom of the cabinets will sit. This way, you can sit the cabinet on the board and screw it to the wall. They will all be neatly aligned. Once the cabinets are on the wall, you can install a screw through the frames to hold them all as one unit. You will need to pre-drill the holes and then screw the frames together.