Because they didn't have photos or the internet in the time of Jesus...
The guards who were sent to capture Jesus and take him to be executed may never have met him previously, so they needed someone who knew him well, who could identify him.
That person was Judas.
This painting by Caravaggio captures the moment when Jesus is betrayed by Judas and taken away by the guards, signalling the start of Good Friday, which ends with Jesus' death on a cross.