I imagine that the author wanted to let people just copy/paste the function into another sketch and made sure that all the code would be there to function correctly.
You are right in thinking that the proper place for those two lines is within setup(), as they would be executed only once, before the loop(). Having them executed every time the function is called is wasted time, but causes no harm either.