Why did the Celtics have game 5 as a home game?

If they win (which they did), they go up 3-2 over the home team and get a bit of momentum or an edge going into games 6-7. That doesn't seem like home court advantage to the home team (Lakers).

Shouldn't a home team get first crack at an advantage in a series? Shouldn't the Lakers have hosted Game 5? Then Celtics get Game 6. And then back to LA for Game 7?

By the home team for the series (Lakers) hosting game 5, they would seem to get an advantage to closing out the series.

I'd almost rather be the visiting team for the series the way it's set up in the NBA.

Do they always go 2 home, 3 away, and then 2 home games? Or did they do this for logistics so the teams didn't have to fly across the country as much?