There are wire fill factors in the NEC - basically if you have a junction of a conductor of this size (gauge) then it must have this many cubic inches to go with it.
The simplest outlet (a receptacle) would have 2 conductors (hot and neutral) and those each require a certain number of cubic inches based on their size (12AWG and 14AWG being the most common). The cubic inches of a box are typically stamped on the box and the amount of conductors ('wire fill') must be below the box capacity. Ground doesn't (didn't?) count in the calculation as it shouldn't carry current normally so it's not a conductor.
If you've worked in a box at or near capacity (especially with a AFCI or GFCI/RCD) you will always put in a larger box given the chance.