Warps are complex but can be divided into four separate components, that the game goes through in order to determine where to put Mario after a warp.
The Source Warp Object (Pipe, warp hole, etc.)
The Source Warp Node
The Destination Warp Node
The Destination Warp Object (Pipe, warp hole, etc.)
The Warp Objects pick their node from their second behavior parameter. The Nodes handle the level transition itself. The chart below shows which values need to be the same for a warp chain to work.