Actually it sounds like she filed a temporary restraining order against him. And the judge granted custody to her temporarily in the order. Which is very much different. Those are granted on a temporary basis until a hearing on the order can actually be heard. I do a ton of this stuff around here and frankly the judges where I live won't order that stuff as part of temporary restraining order but they can. Still parents file them all the time trying to avoid family law court and circumvent the system to get their kids back. Basically make up some bullshit allegations, put it in an temporary restraining order and ask the Judge for custody while it is pending.
And then later you either dismiss the temporary restraining order or you end up looking like a fool on the stand but you got what you wanted in the short term. There is no real repercussions though that deter someone from doing it.