Macron is the president and head of state. He’s elected directly by the citizens of France.
Attal is (was) the prime minister and head of government. ~~He’s elected by the members of parliament.~~ He’s appointed by the president but needs majority support in parliament.
“To form a government” usually means that someone is tasked by the head of state (president or king) to come up with a group of people (cabinet) that has majority support in the house(s) of parliament. That’s easy for Starmer when Labour has a majority. In other countries like the Netherlands, Germany, or Italy, that usually requires a coalition.
That will now also be the case in France.