Why do panda bears eat bamboo instead of meat?

Giant pandas are obligate carnivores that have switched to an almost completely vegetarian diet consisting mostly of bamboo. However, this switch didn't occur due to nutritional reasons - despite its meat-eating classification, the giant panda has a digestive system similar to most carnivorous mammals such as dogs and cats - but evolved because their habitat changed, becoming bamboo forests around 2-3 million years ago.