On my water heater I have five attachment points that have to line up the chimney, the gas line (black iron pipe), inlet, outlet and pressure relief all 3/4 copper pipe. The most recent replacement I could line up the gas, the chimney, and the relief, but I had to use the two 45 deg coupling trick on the inlet and the oulet to get them lined up.
Sharkbite makes a steel lined 24 in 3/4 flex hose that goes from a nipple to copper or pex.
It’s a bit pricey, but way better than messing with all the aggravation of trying to get things all lined up!