Growing up in a small city in southern Poland, part of a religious family and conservative community, Maciej Gosniowski was told again and again that something was wrong with him. “It would be better if I changed myself,” he recalled teachers telling him. “It would be better if I behaved more like a boy. It would make my life easier.” Mr. Gosniowski was beaten by other students who used homophobic slurs he did not yet understand.