They sound so different. How are they the same? There was a form of music called the Habanera during the 19th century in Oriente. It was developed there by a combination of slaves and slaveholders who had left Haiti following the Toussaint L’Ouverture revolution at the beginning of the century. Eventually this form arrived in Havana. The American composer (from New Orleans), Louis Moreau Gottschalk, who was part black, visited Havana and incorporated its form into his music. He is largely forgotten in this country, but is well known to Cuban musicologists. The Habanera in Cuba eventually evolved into the Danzón. In the US, due to Gottshalk, the Habanera became fashionable, and eventually evolved into Ragtime. The Ragtime evolved to jazz around the time of World War I, while in Cuba, the Danzon eventually became Cha Cha Chá, which was one of the antecedents of Mambo (itself influenced by Big Band Swing of the 1940s).
The Puerto Rican-American jazz basist Andy Gonzales puts it this way: Jazz and Salsa are like cousins, and Cuba is the grandfather.