It took him a bit of time to reach the scene, and along the way, he
wondered why the ranger, Erick, took so long to kill one rabbit.
"Erick" certainly is an appositive noun phrase here, but the question is whether it is a restrictive (modifying) appositive or a supplementary (non-modifying) one.
If the appositive "Erick" is semantically restrictive, i.e. it restricts the denotation of "the ranger" then it's most likely a modifier and no comma is required.
If, on the other hand, there is only one ranger then it's a supplementary, non-modifying, appositive that should be set off by punctuation such as commas. In speech, unlike in integrated apposition, supplementary appositives are marked off from the rest of the clause by intonation, i.e. by a slight pause.
If a proper name occurs first, i.e. as head, it is possible for the appositive noun phrase to be integrated, i.e. no commas, as in "We prefer Carmen the opera to Carmen the ballet".