Thomas Whitecloud, the author and narrator of this story, understands the difference between being "lonely" and being "alone." To be lonely means to feel separated from company, to be longing for companionship, to be searching for someone to share experiences or feelings. To be alone means being in solitude, apart from involvements or distractions caused by others. Being lonely is usually not a positive emotion, while being alone may be an opportunity for introspection and personal growth.
The quote you cite comes as the narrator is nearing the end of a journey. He has run away from the residential school in the Southwest that has taken him far from the Wisconsin reservation where he used to live and where his family still lives. As he walks along the train tracks that have brought him back to his home area, he is recognizing how lonely he was, in the sense of being far separated from the people and beliefs and attitudes of his Indian upbringing, while at the school. Now, he walks by himself, alone, but no longer lonely. "Those are never lonely who love the snow and the pines;...In the woods I know there are the tracks of deer and rabbit;"
The author has no physical companions as he speaks, but the world of animals and plants keeps him company as he finishes his return home.