What version of macOS are you using? Beginning with macOS 13.x Ventura, there is a new System Setting in the "Security & Privacy" section called "Allow Accessories to Connect", which controls whether external devices are automatically seen or whether you will be prompted to confirm it is safe to allow the device to connect. I have this setting set as "Automatically When Unlocked" so I'm not prompted for approval every time.
If that is not the problem, then can you narrow down the issue to one specific USB device? Keep in mind the USB device which you connect which is not seen may not be the USB device which caused the problem. The device previously connected to that particular USB port may have caused the problem. You will need to pay close attention to the devices you connect to each USB port in order to figure it out.
I had an older Mac where some USB drives would disable the USB port on my Mac. When I ran out of working USB ports I had to reboot my Mac in order to restore functionality of the disabled USB ports. I gave up and began using a powered USB hub to connect my external drives which "solved" my problem.
Another possibility may be that your device is being unexpectedly disconnected especially if you are using macOS Ventura. If that is the case, then can you disconnect the USB device from the laptop, wait a minute, then reconnect the device (or another USB device) to see if the laptop will recognize it?
You may also want to check the Apple System Profiler USB section to see how much power each USB device is using since each USB port can only provide so much power. You can access the System Profiler by Option-clicking the Apple menu and selecting the first item.
Make sure to disconnect all other external devices in case one of them is causing a problem. Try connecting each device directly to the laptop to see if you still have the same problem. It is possible a particular combination of devices may be triggering the issue.
Or there is a chance there is a hardware issue with the laptop (or perhaps a cable or external device) which will require a repair. In my own personal experience supporting thousands of our organization's Apple laptops, it is fairly common for the USB-C ports to have accidental liquid damage...all it take is a single drop of water splashing into the port from a spill elsewhere on the table. Unfortunately you cannot always see a problem by examining the USB-C port on the laptop because the opening is too narrow to get a good look. I've had a number of laptops which had bad USB-C ports but I could not see the damage until I took the laptop apart and viewed the port directly. If you do, however, see something wrong with the contacts in the USB-C port, then you know that is likely the problem.
FYI, charging and data transfer utilize different pins on the USB-C port which can explain why one works while the other does not. Sometimes rotating the USB-C connector of the cable 180 degrees upside down may allow the device to work if the USB-C port is half bad.
In my own personal experience with the USB-C ports on Macs.....when power works, but data transfer does not (or the other way around), it usually indicates a bad USB-C port on the laptop which will require a hardware repair.