It occurs after the meat has been in contact with open air for a while. It may or may not affect the flavor of the meat but you can be sure that it's not going to be as fresh as meat that's not brown and carries with it a higher risk of carrying microbes. When freshly slaughtered meat is cut into steaks, the muscle tissue comes into contact with oxygen in the air. The myoglobin in the meat binds this oxygen, forming oxymyoglobin and giving the meat a red color.
However, if fresh meat sits for a period of time, generally over the course of several days, the structure of the myoglobin changes. The iron molecule in the middle is oxidized from its ferrous to ferric form and a different complex is formed called metmyoglobin. This compound turns the raw meat a brown color. The meat is usually still safe to eat when cooked, but the brown, unappealing color turns off most consumers. To avoid having your fresh meat turn brown, use it as soon as possible after purchasing it.