This is the general answer, of course. It was revealed to the disciples because God let them see clearly that Moses and Elijah were the ones standing there. Since it was a revelation from God, name tags were not necessary
What IS intriguing about this question is not how they knew who these two men were, but WHY God chose to reveal their identities. In other times, like when Jesus appears resurrected, his true identity was, for a time, hidden. In this instance of the Transfiguration, it was crucial that the disciples see Moses and Elijah, not just an illuminated Christ speaking with two men. Why? Well, Moses was the receiver of the Old Covenant via the 10 Commandments, and Elijah was a great prophet who stressed the importance of the One God. In speaking to these two, Christ gives the disciples the clear idea that He is the fulfillment of the law, and is indeed the One God that Elijah, and all the prophets, have worshiped and preached.
Now, this may seem obvious in 2010, that Jesus is the fulfillment of the Law and all the prophets. But, put yourself in the place of Peter, James or John. They followed this great Prophet and Teacher, but they couldn’t quite understand who He was. Everyone around had a different opinion, and their hearts and minds had not yet been opened by the Holy Spirit to understand all this. When the crucifixion came and their Master was dead, and later when the fullness of Truth was revealed, what a beautiful, miraculous proof and reflection they had that Jesus Christ was truly God! And what a wonderful feast, rosary mystery, meditation and much more we were left with, 2,000 years later!
In Christ and Our Blessed Mother,
Frank