For paint to adhere properly, the substrate must be clean, dry and firm. Otherwise, you may end up painting a cap of paint over moisture and dirt, which will cause the paint to crack and flake quickly. Usually you just scrape off the bad-looking surfaces. If the previous layer of paint is good, it will serve as a base for new paint.
However, there may be so many layers of paint that the whole thing risks losing its grip and coming loose. All that remains is to scrape off all the layers of paint. You can easily test if you need to scrape e.g. a wooden facade. Cut a sample of a 1 cm thick grid pattern where the facade looks tarnished. If the paint in the squares comes off, the fastener is bad. If you scrape so the wood shows, the wood must be impregnated with base oil. Also remember that the paint you scrape off may be toxic. Keep small children away and wear both safety glasses and respiratory protection. One tip is to cover the ground underneath with plastic so you don’t have to pick up paint chips in the flowerbed afterwards.