Link state protocols give every router the same view of the network. Here's how:
Each router creates a Link State Advertisement describing its connections: "I'm Router A. I connect to B with cost and to C with cost "
Routers flood these LSAs to everyone. Every router receives every LSA.
Each router builds an identical topology database from the LSAs.
Each router runs Dijkstra's algorithm to calculate shortest paths.
Because all routers have the same view, they make consistent decisions. This prevents loops without special mechanisms. The trade-off is higher memory usage to store the full topology.