It all starts with a good cleaning. The amount of cleaning depends on the area, kitchen and baths should be wiped down with a mild soap and warm water.
Now some sanding is needed. A medium/fine sanding sponge works great. It can conform to the trim's profile. The idea is to roughen the surface and remove any loose finish. Once this is done, I like to wipe everything down with a liquid sander, Paso is a good product.
This is the initial preparation before priming. A good oil based primer is needed. Apply the primer and allow to dry. For a ultra smooth surface, the primer can be lightly sanded and dusted before the next phase.
Now your trim needs caulking to the adjacent surfaces. This will produce a nice finished look. The caulking is done after the primer has dried.
After all of this, the painting can finally be done.