There are several things to consider here.
Let's look at the contexts for these two passages. At the beginning of John 14, Jesus says,
Let not your heart be troubled: ye believe in God, believe also in me.
In my Father's house are many mansions: if it were not so, I would have told you. I go to prepare a place for you. And if I go and prepare a place for you, I will come again, and receive you unto myself; that where I am, there ye may be also.
He is basically foreshadowing his departure. But he tells the disciples that they are not to be troubled (to be at peace) because He is going to prepare them a place.
Then, in verse 26, He says,
But the Comforter, which is the Holy Ghost, whom the Father will send in my name, he shall teach you all things, and bring all things to your remembrance, whatsoever I have said unto you.
...basically telling them that although He will be gone, He will not leave them Comfortless. He will send the Comforter (the Holy Spirit), which will lead them into His peace. (See also Galatians 5:22)
In Matthew 10, let's start reading in verse 16:
Behold, I send you forth as sheep in the midst of wolves: be ye therefore wise as serpents, and harmless as doves. But beware of men: for they will deliver you up to the councils, and they will scourge you in their synagogues; And ye shall be brought before governors and kings for my sake, for a testimony against them and the Gentiles.
The context, therefore, is about the conflict between those who believe on Christ and those who refuse to believe. If you keep reading, you'll find that the same contrast is found right before verse 34:
Whosoever therefore shall confess me before men, him will I confess also before my Father which is in heaven. But whosoever shall deny me before men, him will I also deny before my Father which is in heaven.
So the peace that Christ came to remove in this passage is the peace between those who believe and those who reject believing on Him.
Notice the contrast of pronouns in these two passages. In John 14:
Peace I leave with you; my peace I give you. I do not give to you as the world gives. Do not let your hearts be troubled and do not be afraid. [Emphasis added]
On the other hand, notice the language in Matthew 10:
Think not that I am come to send peace on earth: I came not to send peace, but a sword. [Emphasis added]
These two things taken together, we can safely say that in the passage in John, Jesus is speaking to His disciples specifically, saying that He is giving them His internal peace. On the other hand, in Matthew, He is saying that He is creating the external division between those who believe on Him and those who do not believe on Him.