Visual studio automatically formats your code, so that you have a clearer overview of your code, and which parts do what.
This only happens if you have set the Indenting option on the Tabs page to "Smart"
The rules for the formatting are defined on the Indentation page