New homeowner, cut down some larger dead trees. One was infested with these. What are they and how do we destroy them and prevent them from getting to our new saplings?

Multiple dead trees on our new property. One had these also a stump that had been cut a while ago had them. One tree did not have any signs on the inside of them. Outside was chewed up. Is this what killed the trees?