Technically, it depends how the cable is built. In USB 2 standard these cables are not allowed at all, and USB 3 standard allows these cables only if they are build according to the standard.
They are not illegal (there is no jurisdiction with laws against them), and they are cannot be banned as they are just cables. They are just stupid, useless and non-compliant according to old specs and thus should not exist at all for any purpose, and they are only compliant according to new specs if made correctly without power supply connection.
As you might be aware, there are USB hosts and devices. To put it simplified according to old USB standards, Type A socket is used on hosts, and Type B socket is used on devices. And hosts are supposed to only be connected to devices, which is why we have cables with Type A plug on one end, and Type B plug on the other end. So you are not supposed to connect two hosts together, or two devices together, so there should be no need for cables with same type of plug on both ends.
The host is also supposed to give power to a device, so there is 5V supply available on host Type A connector, which the device can use for powering itself (e.g. sound interface) or just detect the host for presence (e.g. printer with separate power).
Now, if you have a cable with Type A plug on both ends, it allows you to do unintended things, as you can connect two hosts and their power supplies together. Two hosts cannot communicate between each other, and the power supplies are now also shorted together through the cable. If you turn off one of the hosts, the other host tries to back-feed power into the other host.
As that is not in any way an intended connection, one or both hosts may get damaged, as you are not supposed to connect power supplies together.
So this is why Type A plug to Type A plug cables should not exist, there should be no need for them. But as something always goes wrong, someone used the Type A socket incorrectly on some device instead of Type B socket, and then a Type A plug to Type A plug cable must be used to attach that device with incorrect connector to a standard PC.
Modern USB specs allow these cables to exist for debugging purposes, as some products that are usually USB hosts may be able to go into device mode for debugging purposes by connecting it to another host like a PC. But as explained above, to prevent shorting of the power supply pins together, such a cable must be manufactured so that there is no connection between the power supply pins of the connectors.
The cable should also be specially marked as being such a compliant debug cable, to distinguish them from the dangerous non-standard cables that should not exist.