Why are my bones rotating the wrong way?
Try this:

create the first lower bone, then extrude 3 times, rotate the 4th bone 90 degrees, then ( in edit mode) slightly move the junction point between the second and the third bone in the Y axis, toward the direction you want the chain to bend.
Another way is to check the bone's roll: in the armature tab - display - set to view axes, then trim the bone's roll until the rotation you want is on their x axis with positive values.

You can also add limit rotation costraints to the bones for having them moving only in one direction.