Since I my last edit, which has been a few years, I have replaced various components in the dryer, including thermostats, wires, etc. I discovered there were burn marks on the wire terminals and the component it lead to. The failure was fairly consistent and wondered why it keeps happening. Lo and behold, the terminals I was using were insulated crimp terminals and it was increasing the resistance of the wire causing it to burn out. I never suspected it because there was no apparent melting of the plastic insulator. I wanted to use non-insulated terminals, but they were very difficult to find and removing the insulation from the terminal connector made an unreliable connection.
That NEMA 10 dryer receptacle is a hazard all its own, and may be creating a hazard for you right now.
AC power, as implemented in the USA, has many tricky twists that DC people aren't really prepared for. Some are relevant here; I'll describe them.
I gather you know 240V AC power is supplied from a transformer with a center tap. The center tap is defined as "neutral". There is 120V between either phase and neutral. Neutral has one job: be the one and only current return (in DC parlance, negative, Vss, or ground) for 120V circuits.
AC power has a Safety Ground which is tied to earth via water pipe or driven ground rods, and is carried throughout the electrical wiring (except in older wiring). Safety Ground** has one job: to deflect faults away from humans. Ground is not a current return, except during ground fault conditions.
In theory, neutral might "float" above Earth Ground by several hundred or thousand volts, due to capacitive coupling or leakage in the supply transformer. This would be bad, so neutral is "pegged" to Earth/Safety Ground via a tie in the main service panel. This tie is only at the main panel: never in a sub-panel, junction box nor appliance. As a result, neutral is near earth, and any phase is no more than 120V above earth.
The tie has a beneficial side-effect - if a hot wire touches safety ground, it has a fat current path through the grounding system and the tie back to neutral. This completes the circuit, flows high current and trips the circuit breaker. (If a neutral faults to ground, not much happens, as the voltage difference quite small, being only the voltage drop in the wiring.)
Most dryers use 240V for the heating coils, and 120V for everything else. (120V controls are cheaper). So it needs split-phase 240V - both hots and the neutral.
If you've been counting, you know your 3-prong NEMA 10 is a pin shy of a ground. This is where true stupidity sets in. NFPA (the authors of the Electrical Code) compromised with dryer manufacturers -- reasoning that since dryers are rarely ever unplugged or moved, the receptacle isn't likely to fail. So they authorize tying neutral to ground, even though this is dangerous and would be illegal anywhere else. Sigh.
So if you lose/break/float a neutral anywhere between the dryer and the panel, the 120V loads will not have a return, and will "lift" neutral to the voltage of leg A. Voltages will measure 240/0/240 instead of 240/120/120. Since neutral is now "hot" and it's tied to chassis ground, the chassis of the machine is also "hot". This has killed people.
Which is your symptom.
I'd start by replacing that dangerous NEMA 10 receptacle with a modern NEMA 14 connector, which provides a fourth pin for ground. I'd also retrofit a NEMA 14 plug and follow the instruction's (on the web) procedure to separate neutral and ground on the dryer. Also carefully inspect the wires between the receptacle and the panel. Somewhere in here I think you have a faulty neutral.
If you are unable to retrofit a ground wire, then replace the 30A breaker with a GFCI-type breaker, and label the 4-pin receptacle "GFCI Protected/No Equipment Ground" - but if you do that, make triple-darn sure that you remove that dryer's internal neutral-ground bond!
It's also possible your neutral problem is between the panel and the supply, in which case it would affect everything served out of that panel... but I doubt it.
** Electrical Code purists may dislike my careful choice of words "Safety Ground". That is to convey that it isn't anything like Vss. If you really want to know their Legal Names as specified in the NEC, Neutral is "Grounded Conductor" and Ground is "Equipment Grounding Conductor". Say what!? Of course this invites massive confusion, and both are wrong: Neutral is not grounded (except at the main panel), and Ground is not a conductor! (in NEC parlance, only wires which flow current under normal conditions are conductors.) These are terms only their mother could love, and I suggest avoiding them like the plague.
Best Answer
It looks as if the red connector in the first photo may not be the original, but a past DIY repair. I may be wrong, too.
Either way the wire should have a retaining clip close to the connection. The plastic grate in photo 1 most likely has a clip close to the terminal. If not zip tie the wires to a stable part of the dryer.
This most likely occurred due to vibration and the wire not being secured. If necessary solder the spade terminal to the wire for the most secure connection.