They only did it because Norris agreed to let Piastri pit first to cover Leclerc, if he had pitted first and they bungled the stop they wouldn't have done the switch.
Incredibly dumb from McLaren, creating needless drama. Pit them so late for no reason, all whilst Piastri was closing on Norris by a second a lap, then with Piastri only 3 seconds behind they let Piastri pit first to cover Leclerc. Even without the messed up pit stop Norris would have only come out maybe 5-7 tenths ahead of Piastri. Just mind bogglingly poor strategy, which they weren't even forced into, they just chose to do it under no pressure whatsoever lol.