What is the difference between talking to a saint and talking to a ghost? In both cases the saint and ghost have passed on; therefore, they both are a spirit. So what difference does it make if one spirit is in heaven and the other is in my house?
By forbidding occult contact with the supernatural realm, what the Church is forbidding are the methods and techniques generally used to "summon up" departed human beings or other spirits (e.g., ouija boards, crystal balls, séances, mediums, etc.). It is not forbidding "conversation," so to speak, between those in this life and those in the next; it is only forbidding attempts to manipulate the supernatural realm to obtain forbidden power or knowledge (CCC 2116).
Take, for example, Saul’s attempt to speak with the dead prophet, Samuel, through the medium of Endor (1 Sam. 28:7-20). It was not Saul’s desire to speak with Samuel that was his sin but the forbidden means by which he accomplished it. It would have been perfectly fine for Saul to have prayed to Samuel, asking Samuel for his intercession, but instead Saul had a medium "conjure" Samuel. The text gives us no reason to think that the person with whom Saul spoke was not Samuel—demonstrating that God may allow such contact to occasionally "work" to bring good out of evil (in this case, allowing Samuel to issue the warning to Saul that he would soon die)—but that does not make the forbidden methods lawful.
Prayer to saints, on the other hand, is entirely different. There is no attempt to conjure up spirits, no attempt to seek forbidden knowledge. All that is done is that the petitioner honors God’s friend and asks the saint for prayer.