Fabrics fresh from the fabric store are usually pre-treated with all sorts of dyes and chemicals during the production stage. It sounds pretty alarming, but most of these chemicals aren't the toxic type. They are used to aid in manufacturing - formaldehyde is used to give stability to fibers, bleach is used to whiten them, and starch is used to help with weaving the fabrics.
Giving your fabrics a bath to eliminate chemicals isn't the only reason to pre-treat your fabric. Fabrics can shrink after being washed. If you've sewn a garment without pre-washing, your floor-length skirt could turn into a knee-length skirt and lose a few inches around the waist.
I try to wash my new fabrics as soon as it arrives home. But be sure to check your fabrics care instructions first. Most can be washed, though some may require dry clean only, such as silk and wool. Check the tag on the bolt of fabric at the store for specific care instructions.
If the fabric requires dry cleaning only, it's up to personal preference whether to dry clean it first before sewing or not. I can live without dry cleaning; however, I will pass a hot steamer through to sanitize it.
Like any laundry I do, I wash my fabrics with like colors, and I wash and dry them as I would a finished garment or quilt. I generally like to wash with cold water as it uses the least energy and dry with medium heat or hang to dry, depending on the size. I'll throw it into the dryer if it's large and wide because I do not have space to hang it. If it's smaller, about one to two yards of fabric, I'll hang it up to dry.
Other sewists will use dye catchers to prevent dyes from bleeding into other textiles. You can find these in most laundry sections of your local grocery store.
Fabrics can fray during the whole pre-treatment process. To prevent this, serge the raw edges of your fabric before washing. A narrow zig-zag stitch close to the edge of the fabric with your sewing machine will do if you do not own a serger or overlocker.
For smaller pieces of fabric, place them in lingerie bags to prevent them from fraying and tangling onto other pieces.
Exceptions for bypassing prewash? If your sewing project does not need to be washed later on, for example, decorative pieces, accessories, or bags. Again, this can be up to personal preference.
Once my fabric has been pre-treated, I'll give it a good press then it's ready to cut my pattern pieces. Washing and drying your fabric might seem like a chore initially, but adding this step to your sewing will prevent unwanted surprises in the end.