As @SevenSidedDie has pointed out, making stone boxes is definitely within the rules of the game and the spell.
However, I'd like to point out that this might not always be a very feasible tactic by running the numbers. Stone shape is limited to 10+CL cu. ft. of material.
To fully envelop a medium-sized creature in a stone box using stone shape, you would have to cover the surface of a 5 × 5 × 10 foot box. Excluding the floor, that's an area of 225 sq. ft. At CL 10, that would mean that the thickness of the stone cage is roughly 1 inch. A object made from stone has hardness 8 and 15 hp/inch, according to Damaging Objects. A single 23 damage hit will free the trapped character, which is not out of the ordinary for a 10th level melee characters. In fact, it's average for a character with Str 20, Power Attack and a +2 Greatsword (7+(5*1.5)+9+2=23), and that is without considering damage buffs or adamantine weaponry.
If you can use an existing wall, the thickness increases to around 1.4 inch. If you allow fractional inches for an object's hitpoints, that would increase them to 21, which is still quite easy to break out of.
Alternatively, you could make a cage, with 1 foot holes in it. In this case, at CL 10, you can get (cylindrical) bars with a thickness of 2.85 inch, yielding 42 hp. Such a cage will be harder to break, but apart from preventing movement, it gives cover at best, making it a rather poor choice unless you can get out of range. And once again, note that characters that do have a short effective range can typically break the wall with a full attack or two.
Do note that the cage wall should still be treated like single object with regards to breaking it. The reason being that the rules for breaking objects are abstract and can lead to strange issues if they are not treated as such. For example, by RAW, 20 layers of 1/20'' rock sheet with air in between require 20 attacks (including most area effects since they block line of effect to the next one), while a single 1'' layer can be broken with a single strike.
Comparison with hold person
Overall, making a box or a cage around a creature will stop it for approximately a round or two at best, making it similar to hold person, which is a 2nd level spell for most characters. Not only this, but contrary to hold person, a stone shape box will prevent you from attacking the held person and a cage will not prevent them from hitting you.
Therefore, I conclude that this use of stone shape is situational at best, though it does add to the spells versatility. It does have some applications, such as interrupting spells with 1 round casting time (no valid targets any more), or getting the raging mass of muscles to stop hitting you with a stick for a bit because his wizard friend can't break the box himself.