Some doors slam more easily than others and can occur for various reasons, but the bottom line is that door slamming gets to be a nuisance after awhile. The problem is compounded if it's a door at home that's used often. You have a few ways to remedy this issue, with some being more practical than others, depending on your personal situation.
Add some weatherstripping to your door's jamb -- the area along the inner frame where the deadbolt meets the door frame. A lack of weatherstripping or a damaged jamb area will allow the door to close quicker, thus allowing the door to slam. By filling this area in, it creates friction each time the door closes, thus keeping it from slamming.
Finger Pinch Guard
Finger pinch guards are simple devices that attach to the edges of doors. They not only prevent doors from slamming, but they also create a gap in between the door and the door jamb, preventing finger pinching. Finger pinch guards work well for small children or elderly people, but they're not ideal for doors that lead to the outside as they may let in weather and bugs.
Because doors don't only slam when they're closed, they can also slam open. In these instances, you'll need to rig a door stopper, which comes in many varieties, but essentially they all work the same. A device is connected to either the floor or wall in the area that the door would hit when it opens. By placing a door stopper in this area, you prevent the door and doorknob from making contact with the wall, thus preventing it from slamming open.
Pneumatic/Hydraulic Door Closer
Hydraulic door closers are often found in schools or other public buildings. These devices are usually attached to the tops of the doors and have an arm that connects to a box or cylinder. They're slightly difficult to push or pull open because you're fighting against the hydraulics, but when you let them go, they close very slowly. Another similar device is called a pneumatic door closer, which is often used on screen doors. Attach one of these devices to your door, and its slamming should become a thing of the past.