Pressure and temperature have opposite effects on density. As temperature increases at constant pressure density decreases and as pressure increases at constant temperature the density increases (and vice versa). The change in density for liquids is smaller compared to gases.
But when we talk about the density change when both pressure and temperature increases, how can we say that the density of liquid decreases as we go towards critical point and the density of the gases increases as we go towards the critical point. Since pressure and temperature have opposite effects on density.