Many fans have questioned this, as they find it inconsistent with Samus' well-established fearless character, as well as the fact that she has encountered and defeated Ridley several times before in her life.
Metroid: Other M was meant to delve deeper into Samus Aran's personal life and history, to show that she is also a human being, with both the strength and frailty that comes with it. As a result, the game shows a side of her we have not seen, mostly because most of the other games (except for Metroid: Fusion) dealt with exploration rather than conversations, and Samus hardly did any talking. Several explanations can be given for her reaction to Ridley in the game:
1) Players tend to forget that the game takes place shortly after the events of Super Metroid, which ended with a tragic event for Samus, i.e. the death of the infant Metroid that sacrificed itself for her. Although Samus went back to work, her reactions throughout the game suggest she is still suffering from post-traumatic stress, making it easy for her to get unhinged whenever something unexpected happens. 2) Adding to the stress is the unexpected appearance of Adam Malkovich, with whom she has a complicated history. Nowhere is this more clear than in the scene where Adam sacrifices himself near the end, and Samus loses her composure. 3) Granted, Samus has encountered Ridley several times times before already, because the Space Pirates kept resurrecting him time and again. However, after Zebes was destroyed, she was probably feeling a sense of relief that with the Space Pirates as good as gone, the ordeal was over and she would not see him anymore. That false sense of security made the unexpected encounter with Ridley all the more traumatic; it even triggers a deeply-rooted memory from her childhood, when she met Ridley for the first time.