So I have questions about the priesthood when Peter, James and John appear to Joseph Smith. Were they in full perfect body flesh and bones? If yes, how could that be because in Nephi it says that until the second coming of Christ their dead will not rise (Alma 40:2). The apostles were killed so how could they appear in body while there is no second coming of Christ?
I’m afraid you’ve misinterpreted the words of Alma, not Nephi. And those words were written several decades before the birth of Christ. The “coming of Christ” Alma spoke of was the FIRST coming of Christ, i.e. — His mortal ministry, not his Second Coming. No one could be resurrected until after Christ’s resurrection. It was His resurrection that unlocked the prison of the grave to allow people to be resurrected.
So, I’m not sure where you got that this was the Second Coming. It was the Atonement that was necessary to allow resurrection. And that happened before any of the three died.
Also, John was probably not resurrected. He was allowed to tarry as a translated being. And he would be allowed to stay in that state until Christ came again. It is widely understood that this referred to the Second Coming.