I’m sure that’s part of it, but what people always seem to discount out of hand for no damn good reason is that Stannis was also acting in defense of his life and that of his family. The Hand of the King, the second-most powerful man in King’s Landing, had just been murdered and Stannis didn’t even have the handship to protect himself with.
In King’s Landing, Stannis was a sitting duck – on Dragonstone, he had the defenses of the castle, the ability to interdict anyone travelling to Dragonstone, and the freedom to start building an army.