The first time I found a square formation was in Empire Total War. Since then, I have read some books covering warfare in 17th-19th centuries. Recently I read in the book "The military experience in the age of reason" by Christopher Duffy, that square formations were unusual in 18th century, but most common in early 19th century, specifically during Napoleonic Wars. I always had the idea that a square formation was a defense against a cavalry charge. Further in 19th century, the only square formation I know that existed was in the Battle of Abu Klea (1885). Besides being a defense against a cavalry charge, square formations were used for other purposes? I am now remembering a painting depicting Isandlwana battle with a british square formation against zulu warriors:
But zulu army never used cavalry... Do you have more examples of square formations? Any contribution to this topic will be very welcome.