I’m not aware of any such law in the US requiring car manufacturers to maintain parts availability for a prescribed period of time. I think this is a myth that has been around for a long time and has been restated enough times that people just accept it as fact.
The only shred of truth that may apply is it’s possible that some other countries have such a mandate. If so, and if a manufacturer sells their cars in those countries, they would be required to keep parts available for those countries. And if they did, perhaps those parts could be used on the US versions of cars if they are compatible.
Otherwise, I think it’s more practical to assume that based on the volume of Model 3’s sold, either Tesla or a third party will continue to supply parts. Heck, you can still get replacement parts for a Delorean if you look hard enough.