They're linked to poster rank. The standard poster ranks based on number of posts get increasing amounts of yellow boxes, up to four or five, I'm not sure. Special usergroups like Handbook Writers get a static number of yellow boxes, regardless of post count. Moderators get five blue boxes. Honorary Mods get five green boxes (there's no actual functional difference between a general moderator and a moderator put 'in charge' of a specific section, as far as I'm aware; you'll note that only a few sections even list specific mods as being in charge). PbP DMs are Honorary Moderators within their PbP(s). The Golbal Moderator, Prime, gets five blues as well, while the BGs get five red boxes.
Basically, it's a function of what it says under your username, rather than necessarily your post count.