Certainly transients created by the loads can be a factor once the MCU is running, but the underlined part of your post suggests a more serious supply problem.
Your MCU will not work without a steady supply. If jiggling the cord causes interruptions in that supply, then the wall connection needs to be addressed.
When you plug into the wall supply to turn it on, you probably have a situation of severe "switch bounce." That is, contact may be made and broken several times before a stable contact is established.
One thing to consider is a better switch between the wall supply and your MCU power supply. Another thing is to insert a delay in your program. For example, you can check for the oscillator to be stable and not move on in the program until it is stable for a predetermined period.
John