First, what's actually the same about all these flours is that they are made from wheat. What makes them different is how they're milled, what kind of wheat they're made from, and even what time of year the wheat was harvested. But what it really all boils down to is protein content.
Protein content is directly related to how much gluten can be formed using that particular flour. Gluten helps create structure and determine texture in your final baked good. Flours with low protein contents will generate less gluten and flours with high protein content will create more.
To get the light and airy structure of cakes, you want a flour with very little protein. But to form the dense chewy structure of bread, you want a flour with a lot of protein so that you can create as much gluten as possible.
Here is the approximate protein content of all the common types of flour:
Bread Flour: 14 - 16%
All-Purpose (AP) Flour: 10 - 12%
Pastry Flour: 9%
Cake Flour: 7-8%
The exact protein content varies by brand, by region, and also by country. However, the name given to the flour is usually an indication of how it's intended to be used. If you're having trouble with a recipe written by someone in another country, try to figure out the protein content of the flour they're using and then find your local equivalent.
Substituting flours with different protein contents can get a little tricky. For most intents and purposes, you're safe using pastry and cake flour interchangeably. You can also generally use AP flour for either pastry or bread flour.
If all you have is AP flour, you can approximate cake and pastry flour by adding 2 tablespoons of corn starch to a scant cup of AP flour. Likewise, you can bump up a flour's protein content (and it's gluten potential) by adding a few tablespoons of vital wheat gluten.
What flours do you keep stocked in your pantry?