For the same reason women walk past a tree, yet decide to go into a toilet to urinate. Our culture considers certain parts of our body a taboo, and displaying them in public is frowned upon. In any case, it has become embarrassing for the last couple of generations of men to pee when someone else is watching.
Urinals are remnants of a different era, when men would just pee against a tree and women stayed at home all the time where they had their own toilet. Men had to adapt to this reality from a young age, and it became normal to pee in front of other men, or have showers together (in the army for example). Today things are very different, and even when I was in the army we had private booths for showering, as well as individual toilets at our barracks. And of course nowadays public places such as restaurants also allow women in. What’s this world coming to?
Incidentally, personally I can’t pee at all if there’s someone else watching. Even if my bladder is about to burst, I’ll wait for the next toilet to be empty rather than use a urinal. I just can’t do it. Oh and I’m very careful about the seat, making sure to always leave a public toilet cleaner than I found it (I’m the sort of guy that will even mop the floor if there’s a mop around).