From a security point of view, the use of vlan is something a network administrator must consider in order to separate and segment traffic in a more logical manner. In a switched network with vlans every packet transmitted belongs to a vlan.
802.1q standard is used in the inter-switch communication to allow packets belonging to different vlans to be delivered through trunk links. The receiving switch is capable to understand which vlan the packet belongs to thanks to the 802.1q encapsulation implemented on the sending switch.
DTP (Dynamic Trunking Protocol) is a protocol supported by all the most important switch vendors as it allows a network manager to dynamically configure trunk links between switches through messages exchange between them. This protocol makes your job easier but it opens a security flaw fairly easy to exploit on your network.