Under What Circumstances Does Rock Form Hexagonal Piles?

A friend came back from Northern Ireland-he took some neat pix of the “giants Causeway”-which is a unique rock formation. It is a big mass of basaltic rock, where the rock has split into hexagonal piles. They are so regular looking, it seems like they cold have been man-made. I have also seen these things in other places-the “Devil’s Post Pile” (Wyoming) has rock that looks similar.
What causes this to happen? I know the hexagon is a shape that allows for maximum packing (bees use them for honey storage)…but why don’t they form squares or triangles?

The Giant’s Causeway isn’t a unique formation, there’s another one just across the water.

Ahem, as you noted in the OP. Carry on.

From the wiki link:

It’s just the way the lava cooled.

That Wyoming site is Devils Tower. Devils Postpile is in California.

The semi-regular columns of basalt result from the slow cooling of homogenous lava. This site has a good explanation. And note that while the number of sides is often 6, other shapes are found (including triangles and rectangles). From the link:

Note that those other numbers of sides aren’t regular polygons; they’re regular hexagons that are further broken in some way.