In wet locations you use 100% silicone caulk. Get the kind specifically for bathrooms with 10 year mold and mildew resistance.
If you are not experienced in caulking you should use painters tape to mask off around the area you are caulking, ( I.E. a line of tape running along both sides parallel to the gap you are caulking. ) Have a roll of paper towels and Water or can of denatured alcohol ready.
Apply the caulk so that you have enough to fill the void, it is ok to put a little to much because you used the tape. Use your finger to smooth out the caulk by starting at one end and swiping the length of the run, this pushes the caulk into the void and the extra out onto the tape and your finger, do this once and wipe your finger clean then dip your finger in denatured alcohol and do it again.
Now carefully pull the tape up, it will have caulk on it so do not let it swing into the walls or you will be cleaning up the walls. Now dip your finger in the denatured alcohol and smooth it one last time with light pressure, this smooths out any ridges left behind by the tape.
informative video here
I bet your caulking job will look much better then the previous persons attempt.