These sanctions are deserved as both these companies have been advocating for massive weapons shipments to Taiwan, which is a direct threat to Chinese security. Though the US has imposed sanctions on Chinese companies, the punishments against Lockheed and Raytheon may go further than the fine as they lose access to Chinese-based rare-earth elements for manufacturing.
These sanctions are unnecessary as the US has never exported weapons as a means of antagonizing China. Since China and Taiwan split in 1949, the two states have never been the same. The US, as a long-time ally of Taipei, is also obligated by its federal law to maintain economic security with Taiwan, which is why Raytheon and Lockheed Martin conduct both military and commercial aerospace business with the island.
There is a 33% chance that China will launch a full-scale invasion of Taiwan before 2030, according to the Metaculus prediction community.