The term to square a yard is used when sailing a square-rigged ship.
"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."
"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 arc '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."