CETME (Centro De Estudios Tecnicos De Materiales Especiales) was a Spanish Government military and tech research center established during WW2. It was set up to provide Spanish defense with an R&D capability when foreign sales dried up as Spain was isolated for being a Fascist country.
In 1945, unemployed Mauser engineer Ludwig Vorgrimler makes his way to Spain and gets to work for CETME. He brings a lot of knowledge of the StG 45, which obviously never made it off the drawing boards. The StG 45 is developed into the CETME Model A, chambered for a now-obscure Spanish 30 caliber cartridge.
Meanwhile, about 10 years later, Germany gets permission to rearm and is looking for a new service rifle in the now standard 7.62X51. Germany first acquires and issues a Belgian FAL, named Gewehr 1 (G1). Political issues between Belgium and Germany (who knew) lead Belgium to refuse to license G1 production to Germany. Germany goes looking for a replacement.
Somehow or another, Heckler & Koch finds out about the CETME Modelo A and Modelo C (7.62X51) and decides to license the design from the Spanish government. The HK 91 is submitted for the Bundeswehr service rifle trials, wins, and is adopted as the Gewehr 3 (G3).
So the CETME doesn't look like an HK, HKs look like CETMES....