In order for Spanning Tree to determine which port is the Root port when receiving the same superior BPDU from multiple ports, Root Port Cost is calculated into the cost of the received BPDU. The calculated cost combined with the BPDU will determine the root port, the lowest always wins.
The cost that’s added to the BPDU as it traverses the network is derived by the incoming interface. Each interface speed has it’s own cost associated to it. Here is a table showing the port cost in each of the STP iterations over time.