This phenomena is generally observed when toothpaste is partially
empty tubes but not in fully tubes.
And I'd bet good money that the phenomenon is only observed with plastic tubes and not with metal (typically aluminium) ones.
Note that when you squeeze a soft and hollow plastic object (think bottle or drinking cup) and you subsequently release the deforming force, the object usually returns back to its original shape (or at least partly).
But a thickish aluminium foil will not: its deformation will be mostly permanent.
Now bear in mind that outside our plastic toothpaste tube pressure is $1$ $\text{atm}$.
Both factors combined, the resilience of the plastic tube and the outside pressure, work together to push the paste back into the tube (at least partly).