Rulings, Not Rules
Jeremy Crawford, the lead game designer, called the rules "intentionally silent on these corner cases":
Wild Shape can introduce wild situations. What happens when someone swallows a druid in a Tiny form? Is a druid fecund in beast form? The rules are intentionally silent on these corner cases, leaving adjudication to DMs. As always, I say go with what's best for your story.
The particular ruling (the druid can shapeshift into a specific animal) can lead to a very satisfactory in-game situation. Or it can be utterly boring and devastating, depending on the plot. It is the DM's job to make the right decision.
Aside from the combat, there will always be huge difference between classes' features, so you can't compare (or "balance") them. Some features will be much more useful than another ones in certain situations.
Following the rules-as-written as strict as possible won't help here. In the end of the day, making the game fun an engaging is not about the rules. For instance, if your game is all about picking locks and disabling traps, and you have only one rogue in the party, (s)he inevitably steals the spotlight. You, the DM, have to balance these things by your self — how exactly do class features work in order to not to spoil the fun.
You are the DM and you want to decide, how does magic (the Wild Shape, in particular) work in your world. For this job, what things should you consider in the first place — your own story, the fact if your players have fun, common sense, or nitpicking these minor semantic details in the rules (which are concise and not detailed enough)?
The Adventurer's League Guide describes the role of the DM the similar way:
As the Dungeon Master, the most important aspect of your role is facilitating the enjoyment of the game for the players. You help guide the narrative and bring the words on the pages of the adventure to life. The outcome of a fun game session often creates stories that live well beyond the play experience at the table. Always follow this golden rule when you DM for a group: Make decisions and adjudications that enhance the fun of the adventure when possible.
Wild Shape description is open-ended
PHB gives only basic restrictons of the Wild Shape:
Starting at 2nd level, you can use your action to magically assume the shape of a beast that you have seen before.
Your druid level determines the beasts you can transform into, as shown in the Beast Shapes table.
The only limitations it describes are the creature type, its CR and its flying/swimming speed — pure balancing ones, a sound base for DMs to build their own adventures. As a DM, you are free to apply all the necessary restrictions — the creature size, type, features or appearance. It would be reasonable to discuss this with the player beforehand, say, prepare a list of their wild shapes.
You don't have to though — if you are happy with the default restrictions, just say that all other things are allowed (dinosaurs included), unless it spoils the fun.
It's up to your DM.
We don't have any rules about what has to be true for a cranium rat swarm to form.
We don't know if there are checks involved, we don't know how long it takes, we don't know if the cranium rats have to be mentally compatible, and in particular we don't know how many cranium rats it takes to form a swarm. (You've suggested that 18 cranium rats should be correct, and you derived that number by dividing the hit points of the swarm by the hit points of a rat, but that is your house rule and not necessarily correct.)
It would be an error for us to say "yes you can do this", because someone might then point their DM to the answer and say: "look, rpg.stackexchange says you have to allow this!" and we shouldn't be issuing house rules for you.
I do think this would be a cool thing to have happen, but it would have to be done with the DM's cooperation anyway since you're unlikely to have 18 player character druids in the same campaign.
Best Answer
They were using it as intended. The spell's duration is "instantaneous" and does not require handling the stone to form the shape, just touching it to deliver the spell. It can create barriers and boxes.
However, it does not have any provisions for targeting a creature directly with its constructions, and so it does not restrict you in how to resolve such events. Therefore, just as any event in which the success of failure of the effort is uncertain, you're within your role as GM to decide how to resolve the situation:
If the caster made a heavy slab protrude from a cave wall attached only by a fragile piece, so that it would break and fall on their foes, you would probably use the falling object rules to determine the chance to evade and the damage.
So too, you'd be justified in giving the creature around which the Druid wants to create a stone box a chance to get out of the way, or not, according to your sense of of the situation.
Creative uses of spells are a great part of play, but don't begin and end with the spell description. Any knock-on effects of a spell's use have to be resolved on a case-by-case basis, as with any creative maneuver.