Hello Naidu,
ethernet LAN switches are transparent bridges this means they are not allowed to modify even a single bit of user traffic frames.
STP manages topology redundancy at OSI layer2 by making the lan switches aware of the presence of each other.
This is done by sending and receiving STP messages : BPDUs.
First the root bridge is elected then after this the role of each switch port is decided: any redundant link is made not usable for end user traffic by setting one side as STP blocked port.
A loop free topology is so built.
If anything changes a recalculation is performed and at least one switch port will change its STP state going through different intermediate states in order to avoid the forming of loops in transition.
I would suggest you to read the following, because there are different type of STPs: the more common on Cisco switches is PVST+
http://www.cisco.com/en/US/docs/switches/lan/catalyst6500/ios/12.2SX/configuration/guide/spantree.html
Hope to help
Giuseppe