"Switched" is a misleading wording. After "wenn", the personal form of the Verb (the one that was conjugated according to the person and number, i.e. hätten(plural, third person) as opposed to gesagt, the latter being unpersonal) comes fast always comes at the very last position, except for extreme cases you don't really have to worry about (like combination of Konjunktiv 2 and a modal verb, e.g. "Wenn es hätte nicht sein müssen,"). So it's not about "switching", it's about occupying the last syntactical position (or the first, the second).
Generally speaking, the basic word order in German is Subject-Verb-Object. In the clauses you ask about, putting the verb on the first place has the effect, that the subject MUST be placed second, and not somewhere else.
The dependent clause beginning with the verb behaves as if the first position is already occupied, even if it has a Subject and Object of its own. Actually, this is just typical for subordinate clauses introduced by wenn and dass and is just a usage-based grammatical rule, but this line of thinking may help you memorize it. Example:
Dass du verstanden hast, habe ich gesehen.
Structure of the example: Object, Verb, Subject, everything else.
A simpler example:
Tom sah ich nicht.
Once again, the ground structure is Object, Verb, Subject.
So, in your example, we cannot put the verb anywhere else but on the first position, because the first position is kind of occupied with the main clause with "wenn."
Note, however, that we can also leave out the "wenn" and use the VSO structure for conditions, e.g.
Hätte es nicht geregnet(full version: wenn es nicht geregnet hätte), wäre ich nicht gekommen.