In a breadth-first search, we pick a node to initially visit into a queue and mark that it has been visited. We then repeatedly remove a node from the queue, and add its unvisited adjacent nodes into the queue, marking them visited. This loops until the queue is empty.
Due to the first-in, first-out nature of the queue, nodes are visited in order of shortest distance from the initial node. The shortest distance property only holds for unweighted graphs.