The typical basketball goal at a home is a mobile goal on a pole with a water-filled plastic base or a hard-mounted goal attached to an object like a tree. Bolting the hoop and backboard directly to the tree can easily damage the tree which may lead to rot and decay. The best option is to build a removable frame for the hoop and backboard that will grasp the tree in a vice-like clamp without damaging it.
Cut the 2-by-4 treated lumber into two boards, 36 inches long, using a miter saw.
Attach one board to the back of the backboard. Set the board as high on the backboard as possible. Make it flush with the top for square backboards or slightly below the top for rounded backboards. Drill six to eight 2-inch wood screws through the face of the backboard into the 2-by-4 board.
Clamp the second board to the back of the first so the two boards are flush on each edge. Mark a point on the wood boards that corresponds with the center of the backboard.
Measure the width of the tree with a tape measure. Add 4 inches to the measurement. Mark the board with the final measurement. The marks on the board should be equally distant from the center mark. For example, if the tree is 12 inches wide, the measurement would be 16 inches. The marks on the board would be 8 inches from the center mark so the marks are 16 inches apart and centered on the backboard.
Drill a 1/2-inch hole through the two marks. Drill through both boards and the backboard.
Attach the hoop to the backboard using the bolts included with the backboard.
Position the backboard onto the tree and place the second board on the opposite side of the tree.
Slide the threaded pipe through the holes on the backboard and the second board. Attach a washer and nut to each end of the threaded pipes.
Tighten down the nuts on the second board until the backboard is held securely to the tree. The tightness of the bolts will sandwich the tree between the boards without damaging the tree. Cut the excess pipe off with a hacksaw.