Those gaps were probably meant to accomodate the "standards" in rack shelving:
basically, you would attach a pair of "standards" or "tracks" to your wall by drilling into the mortar joints preferably (so that you could always remove the screws, anchors and refill the holes with mortar for an invisible repair).
Then you hang shelf hangers on the standards or tracks.
Then you set your mantle on the shelf hangers. If the standards are the same distance apart as the gaps on the back of the mantle, the mantle will fit around the standards.
But, those shelf standards are intended to support a number of shelves, not just one.
Also, if you do install track shelving, don't be hesitant to drill your own holes in those standards to line up with the mortar joints in your brickwork.