If you're buying them at the grocery store, consider the time they've already been off the plant. They are covered in wrap which causes condensation, shipped in a truck, etc. Try to buy as fresh and local as possible, only buy the amount you will eat in 2 or 3 days. They need to be kept dry and have air. Some people freeze them or you can slice them and sprinkle some lemon juice and sugar on them (and keep in fridge until ready to eat), and it helps inhibit the mold growth.
Mold loves berries, and usually it's just surface mold. I get flats of berries wholesale, and usually dip them in a 10:1 water and vinegar solution as soon as I get them. This seems to really slow down the time until molding because it kills off existing spores -- I've been able to keep my strawberries for up to six weeks before, but I also bought them straight from the wholesaler through Bountiful Baskets so there was no wondering how long they sat on a shelf.
Strawberries are almost ideal environments for mold to get started: 1) close to the ground to pick up spores; 2) almost constantly moist from dew; 3) there is a particular mold which is extremely common on strawberries, rhizopus stolonifer.