For me it's fine to think they did it out of pure greed (i.e. they realize they are direct competitors to news companies so if they show themselves to bow to this pressure no one will use them for anything controversial again). That way they're more likely to keep doing it in the future, even under new management.
Twitter's still small enough that they can make decisions out of principle, without them being diluted by a corporate structure. This strikes me as something Google might have done a few years ago.
Challenging the gag order was a win-win for them. Were they to lose, they'd have to comply with the gag order, but they could at least benefit from having put up a fight. Because they won, they get to be the champion of the people.
Don't get me wrong, I'm glad they did, and I'm extremely proud of them on principle, but it was the logical way to respond.