Wood generally floats because it's less dense than the water it floats on. However, some woods are denser than water and will tend to sink.
Wood is made of individual fibers, and there is some space in between these fibers. Because of this, most woods will naturally float. Woods with denser fibers and those with little space between fibers, however, will sink. In addition, some wood will float until it is saturated with water, at which point it also will sink. Dense wood can still be used for making boats because the air inside of the boat lowers its total displacement.