The term "box" does not only have to refer to a box. A sexual context is also possible.
Not only gays use the word box to refer to an ass or a bed, among other things. The exact meaning of the term is usually determined by the context.
For example, "nice box" is considered a compliment for a good-looking bottom. If you plan to "jump into the sack" with someone, you feel like fucking.
Interestingly, these meanings around the word "box" are almost always sexual or at least erotic.
Why "box" is used here is questionable. One reason may be that it is mainly larger, more expansive Pos that are called this, as they are indeed somewhat reminiscent of the shape of a box.
Those who want to appear cool and casual in chats also often use the word in order to stand out from other flirting partners and at the same time not to come across as too vulgar. However, the connection between box and bed or box and butt is by no means a creation of recent years. Already in the 1960s and 1970s, in the time of enlightenment and "free love", the term was part of common usage. These are words that have obviously managed to secure a firm place in people's linguistic usage. The special thing about them is that just about everyone knows that they usually refer to sexual liaisons, although the words on their own certainly fall into the category of "juvenile".