Prep work is essential to a paint job lasting its longest. Whether you are doing the job yourself or having a contractor do it, make sure to pay close attention to what prep work is being done. The basics to prep work for PAINT is: Pressure wash, scrape, sand, caulk, prime and then paint. There is different prep work for application of stains. The pressure wash cleans all dirt, mildew and mold residue off the the surface being painted. This ensures the paint adheres as best as possible.
Scraping pulls most of the failing paint away from the surface. This is the weakest points in the existing coat so it is important to take them off so it doesn't fail in the near future. Sanding can be mostly visual preference in this case but it does help discover weak points in the existing coating. Essentially sanding flattens the edges of the failing coating so it isn't such an eye sore when it is repainted.
Caulking cracks is very important because it block water from entering the boards and rotting them from the inside out. Caulk and cracks that were caulked before and any holes or cracks that were formed by animals. Do not caulk under siding boards and in areas that weren't previously caulked by the builder. Chances are there is a reason some areas haven't been caulked. Underneath siding cracks should not be caulked because the siding needs a place to let moisture out of the inside surface.
Spot prime bare areas of wood, metal or stucco with appropriate primers for each. Try to use primers labelled specifically for the surface you are priming. Apply paint after primer dries for the appropriate amount of time.
Basic prep work for STAINS is basically the same for paints. The only thing you need to leave out is the priming. Staining wood or cedar siding functions by the stain soaking into the wood pores of the boards. Priming blocks the wood pores and doesn't allow the stain to function as it was made to do.