you can draw names, like putting everyones name in a hat and randomly selecting.
or you could do something that my gym teacher always did,
take the numbers 1,2,3, or however many numbers of players you need per team.
Count each person giving them one of the numbers, so that one person is number 1, another 2, and 3 and repeat the process.
By the end, each person with the same number go into groups and they become teams.