Construction lumber (2x4s, 2x6s, etc.) has a high moisture content. When brought into a shop, the lumber dries out, causing it to shrink and often twist. Of course, your project will go together easier with straight lumber. Here's a simple solution.

First, select lumber that does not include the center (pith) of the tree. Cut the parts to rough length as soon as you bring the lumber home. Then place the parts in a trash bag, as shown above, and close it with a twist tie. Remove the parts for machining, and return them to the bag until you are ready to assemble them. After building the project, the wood dries, but now twisting of any one part is restrained by the other parts.