Cisco switches use something called PVSTP = Per VLAN Spanning Tree Protocol.
So they run one STP instance for each VLAN, and you can configure the STP root differently for different VLANs.
If you read the scenario you posted carefully you'll notice they mention that different ports are blocking in the 2 VLANs.
The ports between the switches are most often and in this case configured for and operating in trunking mode. Meaning that traffic is tagged (dot1q) or encapsulated (ISL) with information regarding what VLAN it belongs to.