When Saul consulted the witch (medium) of En Dor, was it really the prophet Samuel that appeared?
No. There are several important scriptures to consider before we examine the actual story, recorded in 1 Samuel:28:7-25. The first is the verse immediately prior, which informs the reader that "when Saul inquired of the Lord, the Lord did not answer him, either by dreams or by Urim or by the prophets" (1 Samuel:28:6). God was refusing to communicate with Saul through any means, including His prophets. Samuel, even if he had been still alive, would have had nothing to tell Saul. From this we can infer that the "Samuel" who communicated with Saul was not a prophet of God speaking from beyond the grave.
Another important passage is in Ecclesiastes:9:5, 10, which says plainly that "the living know that they will die; but the dead know nothing...for there is no work or device or knowledge or wisdom in the grave where you are going." When we die, we enter a state the Bible likens to "sleep" (1 Thessalonians:4:13-14), remaining unconscious until the resurrections at or after Christ's return. There is certainly no soul that lives on, able to communicate with the rest of the living.
Knowing this, the entity Saul communicated with could not possibly have been the ghost or spirit of Samuel, or any other human being. That leaves only the spirit realm as a possibility—and given that God had explicitly cut off communication between Himself (and by extension, His angels) and Saul (compare 1 Samuel:13:14; 28:6 and Isaiah:59:2), we are forced to conclude that the "Samuel" conjured up by the medium of En Dor was a demonic spirit masquerading as God's prophet.
We might ask, "If it was really a demon communicating with Saul, why did it tell him the truth?" (1 Samuel:28:16-19; compare 13:9-14; 15:8-9, 26; 31:2-4). We must remember that the primary goal of Satan and his demons is to destroy us. By selectively telling Saul pieces of the truth, the demon posing as Samuel was able to depress him to the point where Saul was no longer able to stand up (1 Samuel:28:20).
The demon used parts of the truth, while posing as a man of God, to paint a picture of hopelessness. "And no wonder! For Satan himself transforms himself into an angel of light. Therefore it is no great thing if his ministers also transform themselves into ministers of righteousness, whose end will be according to their works" (2 Corinthians:11:14-15).