In UK general elections, the party that wins more than half of the seats in parliament usually gets to form the gov’t, making the leader of that winning party the PM.
Except when no party gets more than half the seats, or the so-called “magic number”, in which parties will then team up. This is known as a coalition.