A trade machine is used to trade Pokémon with other players. It has no use in singleplayer.
Trade machines can be obtained by crafting them. A pickaxe is required to retrieve them once they are placed.
It is possible to use dye on a trade machine to change its color. This cannot be done via the crafting interface; the trade machine must first be placed. Only the player who placed a trade machine may dye it. After dying a trade machine, breaking it will still return the default red trade machine as an item.