Try the other USB-C port. The Surface Pro 12 has two, and both can charge. If the other port holds a steady connection, the first one is physically worn or damaged. That’s a hardware fault and a warranty case.
Check the port for debris. With the device shut down and unplugged, shine a light into the port. Lint packed in there is common and stops the plug from seating fully. Clean it gently with a wooden or plastic toothpick, never metal.
Perform a forced restart: Hold the Power button for approximately 20 seconds, release it, wait a few seconds and restart.
Check Windows and firmware updates: Ensure that the latest Surface firmware and USB-C controller updates are installed.
Test with another 65W USB-C PD charger, preferably a Microsoft-approved charger. A 65W rating alone does not guarantee compatible PD voltage profiles.