Among many social mammals, males have erections during competitive situations as a sign of dominance. If you are having a dominance display with another male, you get an erection and wave it around in his face to show what a tough guy you are. Social primates do this all the time.