How do I attach a gate where the swing end is 90 degrees to the wall?
Take a (outdoor rated) board of appropriate thickness and attach it to the wall.

Mount the latch to that board.

Ask permission of your neighbour before drilling holes in his wall.