donn knows the preferred way - remove the caulk first. Especially where silicone was used (e.g. around window frames). Most pure silicones are not paintable, or will soon shed whatever paint manages to stick at first. Also remove or at least cut down any loose or stained caulk.
However, there may be seams where that isn't really practical, or at least not entirely so. An example might be a vertical seam covered with a trim piece, e.g. a typical corner seam. The preferred method is to remove the trim and then cut back the sealant so that nothing is exposed beyond where the trim will be. Paint the trim separately and re-install after applying new sealant as needed. If removing the trim isn't practical, just remove as much exposed caulk as you can and then touch up the caulk after re-painting.
Obviously this is labor intensive, which is probably why so many DIY owners simply paint over everything. It can still look pretty decent from several feet away. For the forst few years, anyway.