"I'll trade you 3 blue jelly beans for 2 green jelly beans."
"I'll trade you my 3 bedroom in neighbourhood "B" for your 2 bedroom in neighbourhood "A." Then the lawyers do some paperwork, and titles are exchanged.
The better question is why do you prefer to do this as opposed to selling and buying separately, and can work the transaction either way without a realtor if that's your concern.
But to trade houses you have to find someone who wants the house you have (without a realtor) which is hard enough. But you also have to find someone who wants the house you have in the subset of people who have a house you want and are interested in getting rid of it. This makes it exponentially harder, as the intersection of these two groups is much smaller than each of the groups individually.
That's why humanity invented money as a medium of exchange. Sell your house for $, then use those $ to purchase another house. You've accomplished your goal of switching houses, and your odds of being able to accomplish the transaction go way up. You may have to pay an extra set of legal fees, but it's probably worth it if you actually want the transaction to go through.
Michael