Every cyclist gets a flat tyre once in a while. The good news is that a prepared cyclist can easily fix the puncture and get back on their way quickly and without a lot of bother. Once you learn to patch a tube, you can travel as far as your pedals can take you (assuming, of course, that no other mechanical difficulties hinder you).
Most bicycles, whether road, off-road, or cruisers, use clincher tyres. The clincher system has a thick rubber tyre that fits into the rim of the wheel. The tyre contains an inner tube that holds air under pressure. Air enters the tube through a valve, of which there are two kinds, Presta and Schraeder1 . The inside of the rim is covered in rim tape so that the nipples of the spokes don't poke holes in the tube. The edges of the tyre are lined with wires to hold onto the rim; this is called the bead.
Your Tool Kit
Your tool kit should include the tools you need to fix a flat tyre on your bicycle and not much more than that. You can get a nifty little under-saddle bag to stow these things in, or you can keep them in a pocket, or in the bottom of your rucksack. The tool kit should be comprised of the following:
Different Kinds of Flats
Most flats are caused by a sharp object that sticks in your tyre and punctures the tube. This happens more often on wet days than on dry ones, because the water and oil on the road make objects stick to your tyre. Sometimes you get pinch or snakebite flats, where the tube is compressed and rips in two places. This means that all the air goes immediately out of the tube. You can try to avoid snakebites by keeping your tyres at full inflation (listed on the tyre wall) and by avoiding riding over deep potholes or trenches because riding over the edge of the far side of the trench can compress your rear tyre.
Your tube can also burst (leaving a huge irreparable rent in it) if the tube gets improperly caught in the rim, if you over inflate the tube, or if you leave your bike in focused direct sunlight. If the tube bursts, you have to replace it with a new one.
Fixing the Flat
Do not attempt to ride on a flat tyre. You may be able to roll forward but you are putting your tyre and your rim at risk, and both of these cost more than a new tube.
Avoiding Flat Tyres Altogether
Keep your tyres inflated to the proper pressure. The pressure is listed on the tyre wall of each tyre. In general, knobbly mountain-bike tyres are inflated to 40-45psi, slick tyres to 70-90psi, and skinny racing tyres to 115-120psi. Air will leak from the tyres slowly, so if you haven't ridden in a day or two, inflate tyres to proper pressure before a ride. Regular cyclists are advised to invest in a decent floor pump: they are inexpensive and make inflating tyres to the correct pressure easy.
Also check your tyres for sharp objects after a ride, particularly after travelling through patches of glass or thorns and after wet days. Objects can lodge in the tyre harmlessly at first. After several more miles of riding, they may work through the tyre and puncture the tube.
Thornproof tubes are available and are moderately effective; the downside is that they are much heavier and more expensive than ordinary tubes. They are not completely impervious, though, as screws and nails will puncture them. Thornproof tubes can be temporarily patched with ordinary patches, so keep the patch kit handy just in case.
Some bike shops also sell plastic strips that go inside the tyre to keep sharp objects from puncturing the tube. However, these may rub against the tube and cause friction flats. For restaurant-delivery riders and other people who literally cannot afford to patch or change a tube, solid-plastic tyres are available at some shops. These have no air inside them so cannot go flat. The drawback is that they are heavy and noisy and the plastic does not give as smooth a ride as the inflated tube.
Chemical products also exist to address this problem. One kind of aerosol is called Slime. It adds a self-sealing layer to the inside of the tube so that any puncture will close itself up and can be applied either preventatively or after the puncture. Its drawback is that it destroys the inner tube within 12 months, after the Slime goes hard.