You should always be careful if your pet is swimming in deep water, pets can drown if they get exaughsted. Once the pet is out of the water, clear away any debris from their mouth and nose.
It's a good idea to hold the pet by their back legs and hang them upside down so any water from the lungs drains out. Put them on the ground with their head lower than their chest.
If your pet is drowning in dangerous water, do not put yourself at risk by trying to rescue them.