What's the best way to prevent my squad members from being shaken?
Don't have an exact source but I had more than 5 shaken soldiers and usually they become shaken after a mission that goes really bad: the person in cause is gravely wounded and someone else died or almost everyone else is gravely wounded as well. It also depends on their current will.
But I kind of learned not to fight this new mechanic and instead use it in my favour. The good thing is that after a person recovers from being shaken they receive a considerable increase in will which would be very hard to achieve otherwise.
So after a soldier becomes shaken, wait for them to heal and take them only on easy or medium missions, keep them in the back and let them finish wounded enemies. Works like a charm every time!
I guess what doesn't kill you really makes you stronger :)
EDIT: There's also a high chance to become shaken if the soldier gets unconscious or strangled by the "thin man" (the viper - the irony).
EDIT2: Since the question is about preventing becoming shaken, I could add the fact that a good prevention is to use the mind shield. Preventing mind attacks like mind control and panic could help a lot on this manner.
If your soldier gets gravely wounded in a mission, there is a chance that the soldier gets shaken. This chance is 20/25/25/30% for the four difficulties.
What is gravely wounded? It means that the recovery time is more than 168 Hours (336 on Legendary) - this is determined at the end of the mission.
How is recovery time determined? Based on the lowest HP percentage at any point in the mission, a number is generated within certain limits. There are four "buckets": up to 20%, 21-50%, 51-75%, 76+%.
Example, your Soldier has 10 HP and takes 6 Damage, which brings him down to 40% health. At the end of the mission, the game looks in the 21-50% bucket to see the range of how long recovery takes and picks a random number from that. If that random number is more than 168 hours (336 on legendary), you're gravely wounded and the game rolls if you're shaken.
Note that the source of damage doesn't play into it, and neither does healing. The game records the lowest your HP ever was. E.g., 10 health, take 6 damage, heal 4 damage, take 3 more damage, heal 4 damage -> Even though you end the mission with 9 HP, the game records that you were down to 4 HP, which is 40% of 10. That percentage is the ONLY thing that counts.
I do note that the spread between best and worst recover time is MASSIVE. For example, a single point of damage (the 76%+ bucket) on Rookie difficulty puts your Soldier out of commission for 5 to 25 days - completely random.
For more technical details, I dug into the source code here.
Bonus Answer: If you recover from being shaken, you get a permanent increase to Will (4 to 13 points) and can't be shaken again - it's like Vaccination.