Japan’s Panasonic, which has been retreating from low-margin consumer electronics to focus more on automotive components and other businesses targeting corporate clients, will make the investment in Tesla’s factory in Buffalo, New York.