Square (sailing)
The term to square a yard is used when sailing a square-rigged ship.

To "square a yard" is to lay the yards at right angles to the line of the keel by trimming with the braces.

Explanation
"Squaring a yard" adjusts the position of the square sails so that they are perpendicular to the keel of the ship. This is done in order to "run before the wind', i.e., sail with the wind directly behind the vessel rather than tacking.

When a square-rigger is running downwind, and the yards are positioned perpendicular to the line of the keel, both sheets that control the yard (braces) are tied off aft (i.e., straight back), leading to the figurative phrase "Both sheets aft."

"Both sheets aft, The situation of a square-rigged ship that sails before the wind, or with the wind right astern. It is said also of a half-drunken sailor rolling along with his hands in his pockets and elbows square."

Further definition
"Square ... A term peculiarly appropriated to the yards and their sails. Thus, when the yards hang at right angles with the mast they are said to be 'square by the lifts;' when perpendicular to the ship's length, they are 'square by the braces;' but when they lie in a direction perpendicular to the plane of the keel, they are 'square by the lifts and braces.' The yards are said to be very square when they are of extraordinary length, and the same epithet is applied to their sails with respect to their breadth."

See also
Square rig
Full-rigged ship
Running downwind
Yard (sailing)
Braces (sailing)

References

Nautical terminology