Yamaha were making musical instruments long before the internal combustion engine was invented. Right after WW2 they saw an opportunity to use their metalworking skills in another money-making field.
Quote from the link below; "The company's intensive research into metal alloys for use in acoustic pianos had given Yamaha wide knowledge of the making of lightweight, yet sturdy and reliable metal constructions. This knowledge was easily applied to the making of metal frames and motor parts for motorcycles."