It could be construction adhesive, which would be hard to completely remove. Use a sharp utility knife to open up the crack. Don't worry about removing material that is still providing a seal, just remove the rough stuff in the opening so the new caulk will be able to bond to solid material. Fill the enlarged opening with caulk and you're done, unless you feel the need to paint it.
BTW, you can't paint conventional silicone caulk.
There are two primary uses for caulk:
- aesthetic gap filler
- functional moisture/air barrier
For the latter, you'd see that wherever you need to waterproof joints (shower panels, exterior windows, etc.)
For the former, it can really be used in any situation where you have two pieces of material meet. Typically this is done when two different materials meet and you want to cover a small gap. Example would be where door trim meets the sheetrock. Higher end finishing would have that caulked before painting.
So, as for these shelves, it's really up to you. One option is to caulk it. Another would be to attach some trim moulding.
As for how to properly caulk, the basic method is:
- cut tip to size
- apply to joint
- smooth to finish
There are tools to smooth it, but I prefer to just use a wet finger (and plenty of paper towels to wipe finger off as you go...)
Note if the gap is too wide, you may need to fill the gap first. I've used foam weather stripping in the past for this.
Best Answer
One standard caulk tube will do a tub plus another.
https://www.homedepot.com/p/GE-10-1-oz-Clear-Silicone-2-Kitchen-and-Bath-Sealant-GE5040-12C/100663319
plus
https://www.homedepot.com/p/HDX-smooth-rod-caulk-gun-10-oz-HD109/203788465
The caulk link above - my go to. The gun is just an example (that brand gun is actually crap and pushes out too much even when no pressure).
The way I caulk a tub is to run a first pass that goes as deep in as possible, hit it with a wet paper towel or sponge (push the caulk in), wait about a half hour, and then do the second coat and smooth the finish.