ANSI stands for American National Standards Institute is a nonprofit association that has been around since the early 1900s. They are more focused on making sure that product is built to a certain standard to ensure it functions properly and has a certain longevity. ANSI is for here in the US.
UL stands for Underwrites Laboratories is another nonprofit that was founded in 1894 and focuses on safety standards for gear regarding fire and other types of safety.
UL has testing standards to ensure that if a piece of equipment, like a motor, fails, that it can safely contain the blast or fire and make sure it meets the standards, all around safety. Some other examples are for testing arc flash safety of distribution equipment.
Both ANSI and UL talk about the design and safety of equipment to ensure that people are safe. ANSI more applies towards production standards and UL applies more towards safety standards. Both standards can be required for devices. For instance, breakers have temperature testing ratings for 50C for ANSI and 60C for UL for the same device.
UL ratings are important for equipment here in the US to ensure that it meets the minimum safety requirements like UL 489 for distribution equipment. UL 508 is for certified Panels.
With distribution equipment, you will always have an ANSI rating because that is what defines the gear to be switchgear or a switchboard. You can have gear that is not UL rated, but most reputable manufacturers will not allow the gear to ship without the UL label. It is up to the customer to ensure that the gear maintains that UL listing when they are making modifications in the field. They will want to ensure that they are installing UL-listed devices into the gear. Everything that makes up the piece of equipment must have a UL listing to make the gear as a whole UL Listed. If a piece of gear is not UL listed, it could cause issues with insurance policies at your facility.