It is mostly a joke for little kids. The whole point is that the word "bark" is being used in two different ways. A tree doesn't really bark like a dog! For some reason, little kids find the idea amusing.
Other jokes in a similar style:
What did the ocean say to the shore? Nothing, it just waved!
Which vegetable is famous for singing? Elvis Parsley!