Two reasons describing different effects.
Sufficiently hot water will shrink a plastic bottle, because the bottles are a thermoplastic. When heated to a certain point, the plastic becomes more plastic, and will deform. This can be seen as shrinking. Also, it's chemical makeup is that of a complex polymer, so it's likely folding onto itself when heated as well.
The reason why water put in a freezer will pop the top is because water expands when it freezes. At a point, it has nowhere to expand to. When this happens, Pascal’s Law tells us that a contained liquid under pressure will exert even pressure on all sides. The water is under pressure because it's volume is increasing in a closed container. The top comes off because it is the weakest point of the container, and so, acts as a pop off valve.
hope it helps