It depends on what it is you're sanding, it's age, what you're painting it with, and how you're painting it.
Sanding in prep for paint, in general, is to lightly roughen the surface so that the new paint will better adhere. In extreme cases, there could also be enough roughness that mild sanding is necessary.
Where age comes into play is a cautionary statement towards the presence of lead based paints. If your home is post 1978, you won't have to worry, anything pre 1970 and I'd recommend having it tested. If lead is present, then DO NOT sand! It is acceptable to encapsulate lead paint by painting over it, or you can strip the surface and start over from scratch.
What you're painting with matters if you're using aerosol paints that lay thin coats, which will accentuate any flaws in the surface. Using an airless sprayer to apply latex is only slightly more forgiving because of the thickness of the paint. Using brushed on latex will hide a multitude of sins, however the surface does need to be pretty defect free for optimal finish appearance.
How you're painting refers to aerosol, brush, roller, or airless application. Aerosol and airless sprayer application will lay thin coats that will accentuate defects in the surface. Brushes will hide pretty well, while a roller will make even the roughest of surfaces nearly smooth in appearance.
Given all that information, what is your project and your plans?
I suffer from CDO ... Its like OCD, but in alphabetical order, LIKE IT SHOULD BE!!!