Crashes and freezes in OS X are mercifully rare, but they do occur. Fortunately, most of them can be resolved readily; and even though a crash or freeze may have any of numerous causes or symptoms, the same procedure works for troubleshooting most of them.
Your first step should be to determine the scope of a problem. Is just one application having difficulties, or is the whole system affected?
Send a report, or not: If an app quits unexpectedly, you know that it's at least part of the problem. App crashes are usually accompanied by an error message. If you see one of these, click Reopen to send Apple a report with details about your system configuration and what went wrong, and then relaunch the app. Or click OK to send the report without relaunching the app.
If you don't want to send Apple information about crashes automatically, go to the Security & Privacy pane of System Preferences, click the lock icon, and enter your username and password to unlock it. Then click Privacy, select Diagnostics & Usage, and uncheck Send diagnostic & usage data to Apple. After you do that, the options in the crash dialog box change to Ignore, Report, and Reopen; only if you click Report is information sent to Apple.
Skip reopening windows: If the app crashes again after you relaunch it, you'll see a message asking whether you want to reopen the windows that were open the last time. I suggest clicking Don't Reopen, on the theory that something in one of the open windows may have caused the crash. Either way, as long as the app functions correctly from then on, you can go about your business. (If it continues to crash, follow the steps below, beginning with "Restart.")
Spinning beach balls and other bad signs
Sometimes, however, an app freezes but doesn't quit. If your symptom is an unresponsive Mac--perhaps featuring the dreaded spinning wait cursor, sometimes refered to as the "spinning beach ball" or as I like to call it, the "spinning pizza of death" (SPOD)--you'll need to narrow down the cause.
Switch to another app: Try switching to another app--for example, by clicking its Dock icon or pressing Command-Tab. If other apps respond, and especially if the SPOD appears only when you hover the pointer over a window or menu belonging to the app that was in the foreground when your Mac stopped responding, try force-quitting that app. One way to do this is to press Command-Option-Esc, select the app in the list that appears, and then click Force Quit. (Sometimes you may need to repeat this once or twice to get the app to quit.) If this force-quitting succeeds, try relaunching the app. More often than not, that will be enough to bring the app back to life.
If relaunching (or force-quitting and then relaunching) an app doesn't do the trick, if none of your apps respond, or if your mouse pointer is frozen, move on to the following steps--try each one, in order, until the problem goes away.
Restart: If you can choose Restart from the Apple menu, do so. If not, press Command-Control-Eject (the Eject key looks like an upwards-pointing arrow with a line underneath it) to force an immediate restart. If even that doesn't work, press and hold the Power button until your Mac shuts down, then press the Power button again to turn your Mac back on.
Check disk space: A startup disk that's extremely low on disk space (10GB or less) can lead to slowdowns and worse. Delete some files (or move them to another disk) to make more space. For help, see "Seven ways to free up drive space."
Try another document: If an app always misbehaves when a particular document is open, try closing it and opening a different document. A damaged or corrupted file could be the source of the problem.
Update your software: Make sure OS X itself, and any apps you use regularly, are up to date, because a software update may have fixed a crash-producing bug. Choose Software Update from the Apple menu to update Apple software and anything downloaded from the Mac App Store; for anything else, use the app's built-in software update feature or download the latest version.
Disconnect peripherals: If you attached any new devices recently--especially USB devices--try disconnecting them. Restart and see if the problem recurs. If not, the device may be faulty or, more likely, it may require updated software or firmware. Contact the device's manufacturer for assistance.
Disable plug-ins: If the app that's crashing includes any extensions, plug-ins, or other extras, try disabling or removing them to rule out the possibility that the add-on software is the culprit.
Try a safe boot: To disable certain software that loads at startup and to run cleanup processes that may resolve random gremlins in your system, try a safe boot: Restart your Mac, and, immediately after you hear the startup sound, press and hold the Shift key until the gray Apple logo appears on the screen. If the problem goes away, restart again normally and try again.
Repair your disk: Disk errors can lead to all sorts of problems, crashes included. Try using OS X Recovery and using Disk Utility's Repair Disk feature to look for and fix common disk errors.
Run Apple Hardware Test: Apple Hardware Test is a special utility you can run to test your Mac's logic board, RAM, graphics board, and other components for errors that could lead to crashes and worse. Apple's support site has complete instructions for using this tool.
Add RAM: If your Mac has a small amount of RAM (say, 4GB or less) and has available slots to add more, try increasing your RAM. Extra RAM can speed up many operations on your Mac and can reduce the likelihood of crashes and hangs related to running out of memory.
If you try all those things and continue to have crashes or freezes, contact the app's developer (if it's a single app) or Apple (if the problem is system-wide) for further advice and assistance.