Correct orientation for t-shaped shelf bracket to minimize stress on anchor bolts
Whether the 2" side up or the 4" side up, it doesn't matter in terms of the stress on the bolt.

We can do a simple analysis as below. In the figure below your T-shaped bracket in drawn in blue while the two bolts are drawn in red. For simplicity we assume that the bracket only contacts the wall via the two bolts at the very top and very bottom end. W is the total gravitational force of your bracket, shelf and its load. The forces on the two bolts are decomposed into perpendicular directions f1~f4.



Basic physics tells us that:



Therefore, the axial (horizontal) forces on the two bolts (f1 and f2) are equal and determined by the ratio of (2+4)/d, which is irrelevant to whether 2" or 4" is up or down. The vertical forces (f3 and f4) will add up to the total weight W, but their exact values are under-determined (but irrelevant to which side is up).



I am responding to Jim's questions in the comment. 

(1) In my figure I clearly shows that f1 and f2 point in the opposite direction, therefore f1=f2. If you insist "use a consistent coordinate system" and "to the right is positive", then f1=-f2, but it doesn't change anything.

(2) Equation 3 is correct. Here we are calculating torque of W using bolt 1 as the origin (fulcrum). We are not calculating momentum or angular momentum. The torque of W is calculated as  and obviously . That how to get equation 3. Or more generally,





BTW this is also why Willk's analysis based on "the longer the distance from fulcrum to end of the lever, the more the force is amplified" is wrong. Willk forgets about the angle between the force and lever arm.