How do you secure electrical outlets in a concrete block wall?
You may be able to secure the boxes with something like these supports



This image shows two supports that need to be separated in the middle.

The support is grasped by one of the short, perpendicular legs.  The longer end of the long leg is slid on an angle into the cavity vertically between the box and the vertical edge of the opening. Then the bottom end of the support (the shorter end of the long piece) is pushed in, slipped down and hooked behind the lower lip of the opening.  The short perpendicular legs then stick out and are wrapped around from the outside edge of the box to the inside. The same is done on the other side.  The box is then locked in place.

This assumes the box has "ears" at top and bottom that prevent the box from being pulled below the face of the wall.