The standard home purchase contract lists several conditions that must be met before the closing will take place, covering issues like financing, inspections, insurance, and more. These conditions are called "contingencies." They're important to give you (the home buyer) an out if, for example, your financing falls through or other uncontrollable events or discoveries create barriers to your finalizing the deal.
Remember, buying a house isn't like buying a television, where you can return it within 30 days if you don't like it. Once the deal is done, it's pretty much done. So it's worth investigating whether you're doing the right thing and creating contingencies allowing you to make these investigations before the purchase is finalized.
You, as well as the home seller, will probably ask that a number of these contingencies be included in or added to the written purchase contract. (As a practical matter, you'll be doing most of this on paper, within your written offers and counteroffers.) In a standard contract, in fact (likely prepared by your state's Realtors' association) many of these contingencies will already be there, requiring you to do little more than check a box.
The contract will build in a certain amount of time (probably several weeks) between the contract signing and final "closing" of the deal. (In some states, this period is called "escrow.") During this time period, you and the seller will be working hard to meet or remove the various contingencies, for example, by securing a loan and scheduling inspections, and will advise the other party of progress being made. If either of you fails to meet or remove a contingency, you can either call off the purchase or renegotiate around the issue.
Some contingencies are quite standard, and both you and the seller would probably be foolish to reject them. For example, a buyer's inspection contingency is quite common -- in which you condition the closing on receiving and being happy with the result of reports from inspectors whom you hire. For more information, see Nolo's article Get a House Inspection Before Buying.
A financing contingency is also common, conditioning the sale on you, the buyer, securing an acceptable loan or other financing with which to purchase the house. While it was once assumed that the buyers would get a loan (particularly if they had a prequalification or preapproval letter from a lender), credit has tightened up in recent years, and enough loans fall through at the last minute that sellers have become nervous. As a result, sellers now tend to favor buyers who can make all-cash offers, leave out the financing contingency (perhaps knowing that, in a pinch, they could borrow from family until they succeed in getting a loan), or at least prove to the sellers' satisfaction that they're solid candidates to successfully receive the loan.
Some buyers add an insurance contingency to their contracts. That's because in recent years, homeowners living in states with a history of household toxic mold, earthquakes, or hurricanes have been surprised to receive a flat out "no coverage" response from insurance carriers. You can make your contract contingent on your applying for and receiving an insurance commitment in writing. For more information, see Nolo's article Homeowners' Insurance: What You Need to Know.
Other contingencies are less the norm, and become a matter for negotiation. For example, the seller might ask that the deal be made contingent on his or her successfully buying another house. If you need to move quickly, you can reject this contingency or demand a time limit. Likewise, you can request that the deal be made contingent on your successfully selling your house; but in a slow market, where it might take you months to sell, the seller is liable to balk at this.
Put your contingencies in writing, most likely as part of your offer on the house, or as part of the contract that you and the seller agree on. For help, see Nolo's Essential Guide to Buying Your First Home, by Ilona Bray, Alayna Schroeder, and Marcia Stewart.