Common gulls can not distinguish between males and females. They can only recognise others by visual gestures and vocal sounds. It appears that you had two batchelor males 'trying' each other out. Obviously their signals soon indicated that they made a gender mistake and the locking beaks is a strength test to see who gives way.
Once a true pair is mated they have to continually display their personallity to their mate every time they meet - like when changing brooding on the nest etc.
This behaviour is quite common with seabirds. Penguins are well known for this too.