As the USDA source Zeina quoted says, the protein myoglobin is the main cause of the red color of meat; it achieves this color when exposed to oxygen. Red meat (or dark meat) is myoglobin-rich, from "slow-twitch" endurance muscles, while white meat has little myoglobin, and is from "fast-twitch" muscles. So it really is the protein in the meat, as you guessed! But we can understand better than that.
Myoglobin is related to hemoglobin, which is in blood: myoglobin has a heme group while hemoglobin has four heme groups. In both cases the heme groups are bound up in a globular protein (a globin); that surrounding structure is very different in the two proteins. Heme groups are good-sized organic molecules, but the important thing is that at their center, there's an ionized iron atom, which is capable of binding to various other things, allowing things like hemoglobin transporting oxygen in blood, and myoglobin temporarily holding onto oxygen the muscle cells will use soon. Myglobin is most present in slow-twitch muscles, which are used frequently or continuously, and so need the stores of oxygen for endurance - these muscles are what we call red (or dark) meat. Fast-twitch muscles, used for quick burst of energy, don't need these oxygen stores, so they don't have much myoglobin.
The central part of heme looks something like this:
The gray bonds around the edges are the connections to the rest of the molecule, which we don't care about right now. It's the various things that can bind to the iron atom (that question mark) that are responsible for the color of both blood and red meat. There are several states we see in meat:
- When there's no oxygen bound to it, it's bound to water, and is purple/blue. We know this as the color of blood in veins, but you can sometimes see this in vacuum-packed meat, which isn't exposed to oxygen at all. The iron is in the +2 oxidation state (two electrons removed).
- With oxygen bound to it, which happens instantly when exposed to air, it's red. This is true for blood which has collected oxygen from the lungs, as well as meat in the state we usually see it. Again, the iron is in the +2 oxidation state.
- With the iron ionized further into the +3 state, it can again bind to water, turning brown. This happens after prolonged periods without exposure to much oxygen, for example, meat that's been stored in its packaging for a while. It also happens when the protein is destabilized by acidity or temperature, explaining why cooked meat turns brown. If you cook it slowly at a low temperature, the protein isn't destabilized as much, and some pink color can remain.
- With nitric oxide bound to it, which happens in both cured meats and smoked meats, it turns pink. Similarly, carbon monoxide in oxygen-deficient gas or charcoal grills can also turn it pink.
There's a great deal of variety in myoglobin content of various meats, accounting for much of the variation in color. It all depends on the animal and the role of the muscle. Remember, the myoglobin is used for temporary oxygen storage. This means that more powerful, frequently-used muscles need a lot of myoglobin - for example, young cattle aren't using their muscles much yet and have less myoglobin, while whale muscles, which are constantly used and need to last through prolonged dives, have 25 times as much myoglobin and look black. This is actually pretty cool from a nutritional standpoint: the redder the meat is, the more iron it has!
Whew! So that's red meat. White meat, on the other hand, is from myoglobin-poor fast-twitch muscles, so it doesn't get in on all that exciting color-changing stuff. Poultry breasts as well as a lot of fish fall into this category. While some fish (like tuna) have plenty of slow-twitch endurance muscle, most fish don't need a whole lot, because cruising in water is relatively easy. They instead have a lot of fast-twitch muscle for quick turns and sprints, with a layer of slow-twitch muscle near the skin - this is the dark layer you see in some fish!
In addition to the Wikipedia articles above, this answer includes significant information from the always excellent On Food and Cooking, by Harold McGee - notably it contains nice little diagrams of the various heme states. Much of the same information can be found scattered around the internet. Wikipedia's Temperature (meat) article briefly covers the cooking transformations. For the variety of meat colors, there's this Exploratorium "Science of Cooking" article or this Library of Congress answer about white/dark meat in turkey.