Unfortunately, there's a bit of confusion on this page. The distinction between「口」and「囗」is not how they're drawn, but the functional role they play in characters.
While「囗」does indeed mean enclosure, the purpose of this component is not, in fact, to enclose other components in characters, but to provide a semantic hint of enclosure in characters to do with surrounding/enclosing something. There are other characters which use「囗」for which「囗」doesn't actually enclose any component at all.
There are several other unrelated components which evolved into squares or rectangles in the modern form, which means that categorising square or rectangular looking components into「口」or「囗」in a binary manner is, to say the least, unhelpful. Things that contain rectangles don't necessarily either have something to do with mouth or surround.
「口」is commonly used for two functions:
- The meaning mouth, extended for actions done with the mouth
- As a distinguishing mark
(1) is common knowledge, so I'll focus on (2). There has been a long history of creating derived characters (Chinese: 分化字) by differentiation from existing ones, as you can only represent so many concepts with pictograms. One of the methods in creating new characters is by adding distinguishing marks, and「口」is one of the more common marks used.
Examples:
「喪」from「桑」 (phonetic loan; both そう)
「古」from「盾」 (Semantic extension. The meaning old for「古」is a phonetic loan;「古」originally meant solid, sturdy, now represented by「固」, hence the usage of a shield「盾」to bring out this meaning)
「商」 (Character is borrowed for the name of the Shang Dynasty. Original meaning measure > divide/quotient, commerce/trade; original character obsolete,「商」now takes on both the name and the meanings.)
「周」 (Name of the Zhou Dynasty. Original meaning arrangement of fields > perimeter; original character obsolete.)
「曹」from「㯥」 (Name of the State of Cao. Original meaning pair > kind, group, as can be seen from「㯥」which is a picture of a pair of bags. Original character「㯥」is obsolete. Note that「口」further changed to「曰」.)
「囗」originally depicted fortifications/walls surrounding a settlement
From this, there were two words that it represented:
One with the meaning city walls > Chinese: city, Japanese: fortifications/castle. The word is now written「城」, but the character evolved into「丁」, which is actually found in「城」:
One with the meaning surround, now written「圍」(Shinjitai:「囲」).
The meaning city walls, apart from in「城」, features most prominently in the characters「正」and「邑」.
「正」originally depicted marching (feet「止」) towards a city「囗」, indicating the meaning military expedition [now written「征」], extended to mean govern [now written「政」], and further extended to mean correct). The sound similarity between「城」,「丁」, and「正」is not a coincidence, and「丁」doubles as a sound component in「正」.
「邑」originally depicted a person kneeling outside a city. As a character component, it is written as「阝」exclusively on a character's right hand side, and is ubiquitous in characters to do with city/towns (都鄉邦郵郡). In fact, there are a myriad of proper nouns in Chinese containing「阝」, which were largely names of (ancient) towns.
Do not get「正」confused with「足」; in the latter, the rectangle originally depicted a person's buttocks, which later graphically became detached.
The meaning surround, apart from several characters listed elsewhere already (「國」「圖」「園」), features prominently in a few characters containing「韋」, where「囗」is located in the centre of「韋」.「圍」is already noted to be the modern form of the word (note that it added another「囗」), but we also have「衛」(protect) and「韓」(fence, phonetically borrowed for Korea). For the word representing surround, feet were added to「囗」to emphasise this meaning, depicting a city being patrolled.
Another very common component which now looks like a square or rectangle was originally drawn as a circle「〇」. This component commonly provides the meaning of circle and/or sound えん/げん/がん.
Note,「員」originally meant circle, now represented by「圓」(Shinjitai:「円」).
Finally, some incorrect descriptions regarding「四」and「回」. These are not written using「囗」no matter how you look at it; they are always wider than they are tall, whereas「囗」is always taller than it is wide (when it is used to enclose other components). They also have nothing to do with mouth, surround, or city wall, and neither shape came from「〇」.
「四」originally depicted breathing out, and contains a picture of a nostril. The nose meaning is preserved in characters like「泗」(snot) and「呬」(breathe out/rest, differentiated from「四」with the addition of a mouth semantic「口」. The character representing this word is now written as「息」). The meaning four is a phonetic loan.
「回」originally depicted eddying currents in water, resembling a whirlpool (now written「洄」).