It is called a reef knot because it was used to "reef" or tie up sails. It is called a square knot from its appearance.
A number of knotting guides have voted this knot "the worst knot", and noted that more deaths and injuries have been caused by it than all other knots combined. Its symmetry and initial feel of security have led to it having a wide and undeserved reputation as a secure knot, which it certainly is not, especially if the ropes are of differing sizes or materials, or if the rope is likely to be bumped.
If you pull on an end, the knot will loosen and invert (turning into a lark's head knot), hence its original purpose: it secured the furled-in sails, and is easily undone one-handedly by a sailor who is holding on with the other hand. The weight of the sail would drag the lark's head undone.
If you want to tie something securely, then investigate the bowline or sheet bend.
Structure:
Tying:
To tie a square knot, tie a left-handed overhand knot and then a right-handed overhand knot or vice versa.
Do not tie two knots of the same handedness. That makes a granny.
The "boy scout" instructions for this knot are: right-over-left and under; left-over-right and through. (The square knot is the first knot most Boy Scouts learn and has been adopted as a symbol by the movement.)
See also: Scouting