The confusion stems from a few issues. First, China has a lot of linguistic diversity -- there are several dialects of Chinese spoken in different regions of China and countless minority languages. Second, Chinese expatriates in Western countries have historically come from Guangdong province (also known as Canton province), and often speak the Cantonese dialect of Chinese, leading many westerners to think that it's frequently spoken in China. Incidentally, the two names for Guangdong are romanizations from two different Chinese dialects -- Mandarin and Cantonese.
The short answer is: Standard Mandarin -- the official language of the country -- is spoken and understood throughout most of China, including increasing numbers of people in Hong Kong, and Standard Cantonese is spoken and understood in Hong Kong, some parts of Guangdong province, Macau, and by many overseas Chinese in Singapore, Malaysia, Canada, the U.S., Australia and Europe.