So John the Baptist wasn't Elijah, but he came
in the "spirit of Elijah". This also explains Jesus
in Matthew 17:10-13.

Jesus had said that Elijah had come already in
John the Baptist and that he had been killed.
John's coming in the spirit of Elijah was a first
fulfillment of the Old Testament prophecy.

Prophecy often has a double fulfillment, and in
this case Elijah is yet to come and restore all
things. Since this has no way been fulfilled yet,
it must take place as Malachi says, just "before
the great and dreadful day of the Lord."