What margin: auto does is to push the element from that side to the limit of the other side, so if you apply auto to both sides then both sides are pushing the element so that makes it centred.
@aaronocampo I was just testing this again and ran into a minor problem.
I made Margin: Auto for Search field so that it would stay on the right side, but it looks that’s stopping the yellow button from staying on to the right side.