When in computer networks it happens that the packets are not full? I have heard that sometimes in UDP that happens, if that’s the case, why not all the space is not used?
The space isn't used if there isn't data to send. If you're writing a letter, you write as much as you need and you don't insist that the last page must be full of writing. And you don't wait until you have something extra to say to fill that page, because that would delay the rest of the letter.
"When in computer networks it happens that the packets are not full."
The above statement is dubious. It is much better to say a packet is either a complete packet or a wrong packet.
Let us assume we are not talking about wrong or testing or artificial situations, where every bet is off. Since we are talking about packets, i.e., in terminologies in the network layer, let us ignoring concerns where we do not have enough application data to send. That is a concern in application layer. We will come back to that point later.
Then what does it mean by "the packets are not full"?
A reasonable way to interpret or understand "the packets are not full" is that some bits in a packet are not used. That is, some bits are not part of the control information nor part of the payload. However, in all computer network protocols that I know of, there is no such thing as free-floating bits in a packet. Every bit of a packet must be used for a particular purpose. That is, it is either part of control information or it is part of the payload. In fact, the length of control information, which usually consists of version, addresses, priority, length, hop number and so on is usually predefined for a group of packets while the length of payload is usually specified by a field in control information. In particular, the length of a UDP packet is specified in the packet itself. I can imagine there might be some niche protocol where each packet must be of some fixed sizes, for example, to look like and behave the same for security reasons. Even for that protocol, every bit in a packet still fulfils a useful purpose, in the sense that the packet is wrong without any of them. I would refrain from calling those packets not full.
You might argue that "packet are not full" could mean that a packet is not full of user data just like some part of pages of a letter is left blank. OK, that is just a decent try to confuse people. As I have emphasized, besides control information, all other bytes in a network packet is called "user data" or "payload" by the most common and established convention as said in Wikipedia entry on network packet.
Now let us come to the application layer. It could happen that the expected or the actual data sent to and received by the receiving application could have some portion that contains no actual data. I would say just that. As an application developer, I will not say anything about whether the underlying packet are full or not. Those network packets is not my business. Those packets is out of my sight.