Disconnect all other external devices in case one of them is causing a problem.
Make sure to connect the drive directly to the computer.
Try each of the other USB-C ports especially on the other side of the laptop. You can also try rotating the USB-C connector 180º upside down as well.....this can sometimes work if the port is half bad.
Make sure to test with another cable as well. If the drive has more than one USB-C port, then try using the other one assuming it is equal to the first one in abilities.
The I/O Boards (aka USB-C ports on the laptop) are a prime candidate for issues because on the 2016-2017 models the connectors wear causing loose connections. Plus in my own personal experience supporting my organization's Macs, the USB-C ports seem to attract liquids & have liquid damage.
The Logic Board is another possibility. Since USB-C ports handle both data transfers and support supplying power to the laptop, they tend to have a higher rate of failure due to the chips managing the circuitry on those ports. Sometimes only one port or chip is damaged/bad, but it can sometimes affect each of the other ports even on the other side of the laptop.
If you have the two port non-touchbar model, then you are in trouble because the USB-C ports are integrated onto the Logic Board, so when they become worn & loose, or damaged, then it is time to replace the laptop since the Logic Board is expensive.
Besides, I do not recommend anyone repairing any of the 2016-2020 Intel Macs for multiple reasons since they have so many design & manufacturing issues/flaws as well as becoming outdated very quickly. Money is better put towards a new laptop.