The name TRIAC actually stand for 'TRIode for AC'. And triode is the ancient name for transistor. But 'SCR for AC' really is a better name. Just like an SCR, a TRIAC turns on by applying a gate current and doesn't turn off until the voltage across the TRIAC becomes 0V.
A TRIAC is capable of conducting the positive and negative half period of an alternating current, provided that the gate current also alters its direction.
The circuit below is a very common switch.
While experimenting, keep in mind that the whole circuit is connected to the mains!
U1 is an optocoupler. An optocoupler consists of an LED and a transistor. When the LED is turned on, the transistor will become conductive. This allows current to flow from the gate to A1. Now current will flow from A2 to A1 turning on the lamp.
This circuit does have a disadvantage: there can be no current flow from A1 to the gate; so the TRIAC will be off during every negative half cycle! Fortunately, this can easily be resolved:
Optocoupler U1 contains a TRIAC instead of a transistor. This allows gate current to flow in both directions. There are also optocouples available that contain a zero-crossing detector, e.g. the MOC3041. In that case R2 and C2 can be omitted.
One last remark: gate current always flows from or to A1. Therefore you cannot swap A1 and A2!