I came across to these brackets in my music theory book of Trinity. I don't know what are these called and what they exactly do in this music?
These brackets indicate a "first and second ending." The measures under the "1" are to be played the first time through and those under the "2" are to be played the second time.
It's a nice method of notation and can be extended to more choices. There are also things like "dal segno" and "al fine" and others. You should check them out; search the internet for music notation.
This link has a nice summary of the most basic repeats and endings.