No, BMW and Mercedes are not owned by the same company, BMW is owned by BMW AG and Mercedes is owned by Daimler AG. They are both German automobile manufacturing companies.
BMW was founded in 1916 by Karl Rapp and it started as an aircraft engine manufacturing company. BMW owns Mini and Roll Royce.
Mercedes was founded by Karl Benz and Gottlieb Daimler. Daimler AG owns Mercedes Benz, Maybach and Smart.