Perhaps you were nervous about him being next to you at the urinal? (I can only guess... I've heard of people who have a "pee anxiety" and are unable to do it when someone is close by).
As for shaving pits/ass in public showers... I'm mostly going to say this is probably not good, on account of all the hair shavings - there could be health code issues as well as potential to clog up the drain with hair, depending on how long or bulky the hair shavings are.
Do any heavy shaving at home where you can control where the droppings are going more easily.
But if all you are doing is passing a safety razor over stubble, there should not be a problem, especially at a gay-friendly gym shower.