The ASME Code is not a law.
What makes it required?
It is up to each jurisdiction to pass laws that require boilers or pressure vessels operating in that jurisdiction to be code stamped. In the US, the states are the jurisdictions, so state laws control ASME code requirements. Some states, such as Texas, Louisiana, and South Carolina, do not require pressure vessels to be code stamped. Those states are known as non-code states. But even if the state doesn’t require stamping per code, it is likely that either the end user or the insurance company covering the facility will require it. The code is a tried-and-true standard for construction of pressure vessels that can be safely operated for many years, so it’s never a bad idea to order a code-stamped vessel, even if it’s not required by law. A summary of code stamping requirements in each state can be found here.