Previously, it was found that the internal energy of a system can be described by two functions which depend on the process. In the present paper, it is shown that in some processes the system must be considered in the phase space and in other processes it must be considered in the momentum subspace. Consequently, the Gibbs paradox in statistical mechanics can be explained. Entropy in thermodynamics and statistical mechanics is always extensive. Like internal energy, it is described by two functions, one of which depends purely on temperature, whereas the other depends on volume and pressure.