Halos (also referred to as aureoles or glorioles) have been used in religious, epic, and mythical iconography in many different traditions to represent sacred figures. In some cases, they have even been used to indicate the authority of a ruler or of a hero. In fact, Homer often describes seeing brilliant, supernatural light that seems to shine around the heads of heroes in battle.
Christian art incorporated the use of halos, seemingly, in the 4th century. At first, only the figure of Christ would be seen showing either a cruciform halo (that is, an aureole with a cross within it) or some sort of radiant crown, as if the sun were shining behind his head, modeled after the image of the classic Sol Invictus, the Roman sun god.
Later, a triangular halo was sometimes given to the Father to symbolize the Trinity, and regular round halos were then typically used in images of saints, the Virgin Mary (whose halo would later evolve in Baroque art into a circle of twelve stars), and prophets of the Hebrew Bible.
But there are some images, especially since the 6th century in southern Italy, showing a square halo. This is indeed quite uncommon, and its use is due to very specific reasons.
Read more:
How geometry was used to express Christian truths in art
Square halos were often used to represent living donors who made possible the execution of a given work of art (namely, a mosaic or a church). Most of the characters we find surrounded by square halos are, in fact, popes and abbots, who commissioned the construction of a church, a public building, or some other work related to liturgical art. These square halos, then, are but an indication of a contemporary figure (with no implication of sanctity attached to them necessarily), to distinguish them from saints who might be accompanying them in the image. In fact, the square shape was understood in Christian art as representing the earth (with its four directions) and earthly existence, as opposed to the circle, understood to be a symbol of infinite existence and, hence, of eternal life.