I don't own this model but I will try to help you as best I can. I will start with this link, go through it and see if there is anything that the support article applies in your case. https://support.apple.com/en-us/HT204652
Let me see if I understand the issue first so that I don't derail this entirely.
2016 Macbook Pro 13"
Apple USB C power cable
USB C to HDMI cable
The two ports / cables noted above no longer friction fit with an audible click as expected causing the cables to wiggle loose if the computer is moved.
With respect to the power cable, if it wiggles loose, the machine goes to sleep.***
Can you examine the cable ends and the computer's corresponding ports for any physical damage that might be causing an incomplete connection?
Check the cable ends and corresponding port(s) for any debris that might be preventing the cable(s) from entering fully. It is possible that you may not be able to see anything.
On the debris note, it may be the case that any debris might be too deep into the port to provide visibility. Personally I would open up the computer by removing the bottom lid. You won't need to touch anything inside, you can simply use a can of compressed air to push out any debris. Even if you don't see anything with the bottom lid off you should still blow some air to push out anything that might be present. While the machine is open scan the machine's innards to understand if you see anything that looks like corrosion. If there is any it will be fairly small as all the parts are very small. You can use a magnifying glass to get a better view.
- Now, I know I haven't provided any link thus far because I am tackling the problem reported from the perspective of confirming the issue, ensuring I understand and then use some simple steps which may pull some more information from you which can help us narrow the issue down more specifically (to isolate the issue). Also, I am not suggesting that there is a hardware issue, I can't diagnose from where I am sitting but instead, the steps a set of simple steps to probe, analyze and hopefully isolate the issue down to a part or affected part and from look at some eventual resolution.
- It might even be the case that this is wear and tear which would be very disappointing because Apple should make areas that get a lot of physical user interaction (like ports) a more rigid, durable design but maybe this is not the case.
*** I believe this is not expected behavior, your machine should not fall asleep if the power cable is disconnected. If you experience issues with sleep, wake, power, charging your Mac notebook battery, or other power-related symptoms, you might need to reset the SMC (System Management Controller). Review https://support.apple.com/en-us/HT201295 for specific steps that correspond to your MacBook Pro.
Some links, check these later (After entering the text above I did find some links - as with anything review before proceeding)
Some links but try the above first. Try to understand what the case is for your machine. A lot of people report issues that are apparently the same but the actual source of the problem may vary widely.
Hope this helps, let us know how it goes.