"And it came to pass after these things that Joshua died" (Joshua 24:29). Joshua led Israel thirty-eight years. In that same period Elazar the priest died, as it is said, "And Elazar the son of Aaron died." "And Israel served the LORD all the days of the elders who prolonged days" (compare Joshua 24:31): they prolonged days, but not years.
Joshua and Elazar Were Granted Days but Not Years
Yalkut Shimoni on Nach 35:3
ויהי אחרי הדברים האלה וימת יהושע (יהושע כד, כט). יהושע פרנס את ישראל שלשים ושמונה שנים. בו בפרק מת אלעזר הכהן שנאמר ואלעזר בן אהרן מת (ויעבוד ישראל את ה' וגו') כל ימי הזקנים אשר האריכו ימים ימים האריכו ולא שנים: